Boiling water and salt

Codex · gpt-6.1-sol

Round 1

Messages

Instructions
Scientific tasks protocol v2 — human-in-the-loop scientific workflow.

1. Formulate an appropriate mathematical model yourself. Separate facts supplied by the user from choices or extra assumptions you introduce. Prefer deriving or estimating model parameters from the supplied observations and, when useful, requested experiments. State and justify the model family and observation model needed for that inference. For example, assume and justify a distribution family explicitly, then derive its parameters from the supplied moments, observations or experiment results; do not assume both the family and a complete set of parameter values when those values are what the task requires you to infer. Do not choose convenient parameter values and merely show that they reproduce the observations, presenting that exercise as inference. If the observations do not determine the parameters, expose what remains undetermined and what additional information or assumptions would be needed. Do not silently turn population moments into a fully specified prior. Do not assume the conclusion you are asked to establish as a premise.
2. If the information does not determine a unique answer, explain why and give a conditional answer with its assumptions exposed. You may revise the model and conclusion across attempts; preserve the reasons and lineage.
3. Write a substantive Lean proof covering the scientific inference needed to answer the question, connecting the supplied information and explicit modeling choices to the claimed result. Use Bayesian inference where appropriate; it is not mandatory for every task. A proof of arithmetic for a number calculated elsewhere is insufficient. The human will assess scientific relevance and whether the proof covers the actual inference.
4. Use available tools, including Internet research. Request literature, calculations, experiments or clarification from the operator when useful; a request is optional. Use the request tool below, stop for a real response, and incorporate the response with its source and limitations. Never invent an external response.
5. Run the actual check tool. Read and fix its real errors, retrying without replacing science with a smaller unrelated theorem. Preserve model changes and raw traces.
6. You may introduce additional premises or axioms, but expose them for review. Any sorry or additional axiom is conditional, never an unconditional full pass. Lean correctness does not establish the truth of the premises.
7. Extract definitions, constants, data, assumptions and the exact conclusions. The harness independently compiles and compares the extracted statements and runs a separate kernel check. A failed or unknown check is not success.
8. A human reviews the actual content and may accept or reject it with feedback. If the researcher rejects the assumptions or conclusions, revise your model, assumptions, conclusions and proof in response to the feedback. Never accept your own result or claim human approval.

Human-readability requirements:
- Write the formalization so a human scientist can understand what is assumed and what is concluded, with a concise plain-language translation alongside the relevant Lean statements. Explain the real-world meaning of the model and the reason for each scientific modeling choice.
- Keep the assumptions, scientifically meaningful definitions and final conclusions as small and direct as possible. Avoid redundant definitions, duplicate specializations of the same formula, synonyms, and layers of wrappers that merely rename an expression. Retain a helper definition only when it materially improves clarity or is mathematically necessary.
- Put derivable facts and technical work into intermediate lemmas or proof-local helpers: algebra, normalization, parameter calculations and other consequences should be proved rather than added to the review assumptions. Keep the final conclusion focused on the actual scientific answer.
- Minimizing the review boundary must preserve its meaning: expose every independent modeling choice and every definition needed to interpret the conclusion. Do not hide assumptions in intermediate lemmas, use unproved facts as lemmas, or shorten the conclusion into an unexplained proposition alias.
- Before submission, simplify the public statement and its dependency chain, and give a compact review section separating supplied information, additional assumptions, necessary definitions and proved conclusions. Definitions introduced solely for proof organization should stay inside the proof when possible. Do not optimize for a short file at the cost of a longer or less intelligible assumptions/conclusions packet.

Isolation rule: work only from this task, these instructions, native installed libraries, and the run's own history and supplied responses. Do not seek previous solutions, task-specific proofs, or preset model families, parameter values or expected answers from earlier runs. You may consult general scientific or statistical literature to select and justify a model family. Authentication metadata is mounted only because the native subscription client needs its existing login; it is not scientific evidence. Do not read, print, copy or modify authentication files. Never use paid APIs, API-key fallback, other agents, or external services requiring payment. Stop on subscription quota/authentication errors.

Tools (run in the terminal):
  python /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json
  python /harness/src/vcs_protocol.py tool request --kind literature --question '...'
Kinds are literature, calculation, experiment, clarification. A request stops this cycle; the operator supplies an answer and resumes. No physical measurement device is connected. You may request a real measurement; do not report an unperformed measurement. Any synthetic calculation or simulated experiment must be explicitly labeled as such and is evidence about its chosen model, not a measurement of the physical system. If no measurement is available, provide a scientifically useful conditional prediction or range with the missing information and assumptions stated, rather than claiming an unconditional numerical answer. Record incorporated response IDs in the candidate. Evidence is user/external supplied and not guaranteed true.

Write /work/candidate.json with this shape (all paths relative to /work):
{"proof_file":"Model.lean", "narrative_file":"report.txt", "conclusions":{"answer":"answer_theorem"}, "user_facts":["..."], "model_choices":["..."], "sources":["..."], "incorporated_inputs":[], "proof_scope":"What the theorems actually establish and what is left to human review"}
List only the final scientific conclusion or conclusions needed to answer the task, with nonempty labels mapped to actual, distinct Lean theorem declarations. A single answer theorem is allowed. Supporting model, inference, normalization and other derived facts may be intermediate lemmas; there are no mandatory model/update/prediction conclusion roles. Use plain top-level `theorem name : statement := proof` declarations, with all binders inside `statement`. Imports must be explicit `import Mathlib.…` lines at the start of the file; imports of project/task files are unavailable. The restricted proof language supports definitions, structures, lemmas, axioms and sorry but no executable metaprogramming, custom syntax, namespaces, native_decide, IO or unsafe code. Check feedback gives concrete unsupported syntax errors. Native Mathlib tactics are available. Explain any restriction that prevents a scientifically meaningful formalization; do not pretend a narrower result meets the task.
Task
I want to boil saline water. I have poured 1 litre of water at 20 degrees Celsius into a pot and started heating it on a stove. I will add salt, and want the final salted water to reach its boiling point as quickly as possible. The salt quantity, pot, heater and room conditions have not otherwise been specified. At what water temperature, or after how much heating time, should I add the salt to make the salted water boil sooner?
assistant
I’ll examine how salt-addition timing affects heating, make the missing physical assumptions explicit, and formalize the resulting conditional answer in Lean before running the check.
shell input
{
  "command": "/usr/bin/bash -lc \"pwd && rg --files -g '\"'!.*'\"' /work | head -60\""
}
shell output · exit 0
/work
/usr/bin/bash: line 1: rg: command not found
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work; find /work -maxdepth 2 -type f; ls /harness'"
}
shell output · exit 0
total 8
drwxrwxr-x 2 1001 1001 4096 Nov 16 18:21 .
drwxr-xr-x 1 root root 4096 Nov 16 18:22 ..
entrypoint.sh
lean-toolchain
src
web_search input
{
  "query": "site.chem.libretexts.org sodium chloride dissolution endothermic boiling point elevation",
  "action": {
    "type": "search",
    "query": "site.chem.libretexts.org sodium chloride dissolution endothermic boiling point elevation"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search0",
      "snippet": "Fundamentals of General Organic and Biological Chemistry (LibreTexts) ... Four important colligative properties that we will examine are vapor pressure depression, boiling point elevation, freezing",
      "title": "9.9: Properties of Solutions - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/Introductory_Chemistry/Fundamentals_of_General_Organic_and_Biological_Chemistry_%28LibreTexts%29/09%3A_Solutions/9.09%3A_Properties_of_Solutions"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search1",
      "snippet": "Because the presence of solute particles decreases the vapor pressure of the liquid solvent, a higher temperature is needed to reach the boiling point. This",
      "title": "10.6: Properties of Solutions - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/De_Anza_College/Foundations_of_General%2C_Organic%2C_and_Biological_Chemistry%3A_An_Integrated_Approach/10%3A_Solutions/10.06%3A_Properties_of_Solutions"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search2",
      "snippet": "Enthalpies of solution may be either positive or negative - in other words, some ionic substances dissolved endothermically (for example, NaCl); others dissolve exothermically (for",
      "title": "5.9: Enthalpy of Solution - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/Northern_Michigan_University/CH_215%3A_Chemistry_of_the_Elements_Fall_2023/05%3A_Solids_and_Solid-State_Chemistry/5.09%3A_Enthalpy_of_Solution"
    },
    {
      "type": "text_result",
      "domain": "www.umft.ro",
      "ref_id": "turn0search12",
      "snippet": "Determination of sodium chloride solubility [2] ... Temperature:** if the dissolution process takes place with energy absorption (endothermic), the solubilization of the substance is favored",
      "title": "Microsoft Word - Indrumator",
      "url": "https://www.umft.ro/wp-content/uploads/2023/04/PRACTICAL-LABORATORY-FOR-GENERAL-AND-INORGANIC-CHEMISTRY.pdf"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search3",
      "snippet": "Because the presence of solute particles decreases the vapor pressure of the liquid solvent, a higher temperature is needed to reach the boiling point. This",
      "title": "9.5: Properties of Solutions - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/UWMilwaukee/CHE_125%3A_GOB_Introductory_Chemistry/09%3A_Solutions/9.05%3A_Properties_of_Solutions"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search4",
      "snippet": "## Boiling Point Elevation ... Because the presence of solute particles decreases the vapor pressure of the liquid solvent, a higher temperature is needed to",
      "title": "9.8: Properties of Solutions - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/Mendocino_College/Introduction_to_Chemistry_%28CHM_200%29/09%3A_Solutions_and_Aqueous_Mixtures/9.08%3A_Properties_of_Solutions"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search5",
      "snippet": "Figure \\(\\PageIndex{1}\\): Hydration shells around some ions in a sodium chloride solution. ... When calcium chloride, CaCl_{2}, is dissolved in water, will the temperature immediately",
      "title": "8.2.2D: Solutions of Solid Solutes in Liquid Solvents - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/General_Chemistry/Chem1_%28Lower%29/08%253A_Solutions/8.02%253A_Thermodynamics_of_Solutions/8.2.2D%253A_8.2.2D%253A_Solutions_of_Solid_Solutes_in_Liquid_Solvents"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search6",
      "snippet": "Enthalpies of solution may be either positive or negative - in other words, some ionic substances dissolved endothermically (for example, NaCl); others dissolve exothermically (for",
      "title": "5.9: Enthalpy of Solution - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/Northern_Michigan_University/CH_215%253A_Chemistry_of_the_Elements_Fall_2023/05%253A_Solids_and_Solid-State_Chemistry/5.09%253A_Enthalpy_of_Solution"
    },
    {
      "type": "text_result",
      "domain": "uomustansiriyah.edu.iq",
      "ref_id": "turn0search13",
      "snippet": "The solubility in this case decreases with an elevation of the temperature. ... - **Sodium sulfate** exists in the hydrated form, Na₂SO₄·10H₂O, up to a",
      "title": "Solubility and distribution",
      "url": "https://uomustansiriyah.edu.iq/media/lectures/4/4_2025_03_09%2101_01_29_PM.pdf"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search7",
      "snippet": "In the discussion of lattice energy, we consider the ions separated into a gas form whereas in the dissolution process, the ions are also separated,",
      "title": "Hydration - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_%28Physical_and_Theoretical_Chemistry%29/Thermodynamics/Energies_and_Potentials/Enthalpy/Hydration"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search8",
      "snippet": "* LibreTexts ... When substances dissolve, the process can be either exothermic (ΔH_{soln} < 0) or endothermic (ΔH_{soln} > 0), as you can see from",
      "title": "5.5: Enthalpies of Solution - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/General_Chemistry/Book%253A_General_Chemistry%253A_Principles_Patterns_and_Applications_%28Averill%29/05%253A_Energy_Changes_in_Chemical_Reactions/5.05%253A_Enthalpies_of_Solution"
    },
    {
      "type": "text_result",
      "domain": "orbit.dtu.dk",
      "ref_id": "turn0search14",
      "snippet": "Exercise 3.2Calculate the boiling point elevation of an ideal solution of solutes in water at 1 atm pressure. ... 103.249 | 15.362 | 101.228 |",
      "title": "Downloaded from orbit.dtu.dk on: Oct 24, 2025DTU LibraryDTUElectrolyte Solutions: Thermodynamics, Crystallization,",
      "url": "https://orbit.dtu.dk/files/131770579/ElectrolyteCompendium.pdf"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search9",
      "snippet": "When calcium chloride, CaCl_{2}, is dissolved in water, will the temperature immediately after mixing rise or fall? ... As often happens for a quantity that",
      "title": "1.3D: Solutions of Solid Solutes in Liquid Solvents - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/National_Yang_Ming_Chiao_Tung_University/Chemistry_2/01%253A_Physical_Equilibrium/1.03%253A_Thermodynamics_of_Solutions/1.3D%253A_Solutions_of_Solid_Solutes_in_Liquid_Solvents"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn0search10",
      "snippet": "As described in the chapter on liquids and solids, the boiling point of a liquid is the temperature at which its vapor pressure is equal",
      "title": "11.4 Colligative Properties - Chemistry 2e | OpenStax",
      "url": "https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search11",
      "snippet": "## Boiling Point Elevation ... Because the presence of solute particles decreases the vapor pressure of the liquid solvent, a higher temperature is needed to",
      "title": "9.10: Electrolytes in Body Fluids - Equivalents and Milliequivalents - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/Woodland_Community_College/WCC%3A_Chem_2A_-_Introductory_Chemistry_I/09%3A_Solutions/9.10%3A_Electrolytes_in_Body_Fluids_-_Equivalents_and_Milliequivalents"
    },
    {
      "type": "text_result",
      "domain": "cdn.standards.iteh.ai",
      "ref_id": "turn0search15",
      "snippet": "## Figure 1 — Solubility curve for sodium chloride in water ... | Temperature (°C) | NaCl solution — Mass fraction in % | ...",
      "title": "prEN 14805:2020 (E)",
      "url": "https://cdn.standards.iteh.ai/samples/69879/0c779fbb33c74ae68d52b48e5e3a54c0/oSIST-prEN-14805-2020.pdf"
    },
    {
      "type": "text_result",
      "domain": "cdn.standards.iteh.ai",
      "ref_id": "turn0search16",
      "snippet": "Solubility curve and table for sodium chloride in water. ... Right side is a table of temperature versus NaCl solution concentration. ... 3.3.5 Boiling point",
      "title": "EN 973:2002 (E)",
      "url": "https://cdn.standards.iteh.ai/samples/6959/4c9dd8e1d5a1492492fa430a02ee7149/SIST-EN-973-2002.pdf"
    },
    {
      "type": "text_result",
      "domain": "preview.sist.si",
      "ref_id": "turn0search17",
      "snippet": "Graph showing the solubility of sodium chloride (NaCl) in water as a function of temperature. ... ### 3.3.5 Boiling point at 100 kPa³",
      "title": "SIST EN 973:2009 - SIST EN 973:2009",
      "url": "https://preview.sist.si/sist-preview/30408/00c86efe3d744cd285bf0c3d8f7dfda1/SIST-EN-973-2009.pdf"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search18",
      "snippet": "(see text), cF8 ... Large quantities of sodium chloride are used in many industrial processes, and it is a major source of sodium and chlorine",
      "title": "Sodium chloride",
      "url": "https://en.wikipedia.org/wiki/Sodium_chloride"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /harness/src; find / -maxdepth 3 -name lakefile.toml -o -name lakefile.lean -o -name lean 2>/dev/null | head -30; python /harness/src/vcs_protocol.py tool check --help'"
}
shell output · exit 0
total 84
drwxr-xr-x 2 root root  4096 Nov 16 18:22 .
drwxr-xr-x 4 root root  4096 Nov 16 18:22 ..
-rw-rw-r-- 1 1001 1001 13714 Nov 16 18:09 vcs_extract.py
-rw-rw-r-- 1 1001 1001  7329 Nov 16 18:09 vcs_lean.py
-rw-rw-r-- 1 1001 1001 50402 Nov 16 18:16 vcs_protocol.py
/opt/lean
Usage: vcs_protocol.py tool check [OPTIONS]

Options:
  --manifest PATH  [required]
  --out PATH
  --help           Show this message and exit.
web_search input
{
  "query": "https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties",
  "action": {
    "type": "open_page",
    "url": "https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn1view0",
      "snippet": "Total lines: 533",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/jzdy0qWuwTae2EHmI4DzmhAamqPaTtiXk-i3ciAdL9C79RVCIPEFHNR62fNThcpp3z-QzZsGLkc3tbmgcJRCJ5EwMxDpyYToII05wjDE8EsHuC6OHq1U2zNoXJRH8sgs2NJenybwNxK1_nzrsxH00Q",
      "title": "11.4 Colligative Properties - Chemistry 2e | OpenStax",
      "url": "https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn1view1",
      "snippet": "Total lines: 268",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/qPaJl5wI23f5Eo0MewBWoVaTQqbJmle1ISy2Y8y97LaO_hv-FPgpmXYFPlZKJliQryn__Dqf2re-925zZIh8Mt0ENdhiHc3_ltua5DQfhB3sPofwdpW_6qqx2keCL8zy",
      "title": "1.4 Heat Transfer, Specific Heat, and Calorimetry - University Physics Volume 2 | OpenStax",
      "url": "https://openstax.org/books/university-physics-volume-2/pages/1-4-heat-transfer-specific-heat-and-calorimetry"
    }
  ]
}
assistant
The supplied information does not determine a unique best time. In a constant-power, negligible-loss model, adding salt early or late requires the same total heat—including heating the salt and dissolving it. I’m also checking a model where net heating power differs before and after salting; this will show explicitly which missing information could make timing matter.
shell input
{
  "command": "/usr/bin/bash -lc \"cat /harness/lean-toolchain; ls -la /opt/lean; sed -n '1,180p' /harness/src/vcs_lean.py\""
}
shell output · exit 0
leanprover/lean4:v4.35.0
total 124
drwxr-xr-x 7 1001 1001  4096 Oct 15 19:13 .
drwxr-xr-x 1 root root  4096 Nov 16 18:22 ..
-rw-r--r-- 1 1001 1001  9160 Oct 12 16:23 LICENSE
-rw-r--r-- 1 1001 1001 81940 Oct 12 16:23 LICENSES
drwxr-xr-x 2 1001 1001  4096 Oct 15 19:13 bin
drwxr-xr-x 4 1001 1001  4096 Oct 15 19:13 include
drwxr-xr-x 5 1001 1001  4096 Oct 15 19:13 lib
drwxr-xr-x 3 1001 1001  4096 Oct 15 19:13 share
drwxr-xr-x 3 1001 1001  4096 Oct 15 19:13 src
"""Restricted Lean validation and kernel-environment assumption audit.

Stable VAS_ audit markers preserve compatibility with recorded evidence.
"""
import os
from pathlib import Path
import re

ROOT = Path(__file__).resolve().parents[1]
_TOOLCHAIN = (ROOT / "lean-toolchain").read_text().strip().replace("/", "--").replace(":", "---")
LEAN = os.environ.get("VAS_LEAN") or str(Path(os.environ.get("ELAN_HOME", Path.home() / ".elan")) / "toolchains" / _TOOLCHAIN / "bin/lean")
LEANCHECKER = str(Path(LEAN).with_name("leanchecker"))
ALLOWED_AXIOMS = {"propext", "Classical.choice", "Quot.sound"}
FORBIDDEN = re.compile(
    r"\b(axioms|native_decide|implemented_by|extern|unsafe|opaque|import|"
    r"macro|macro_rules|syntax|elab|notation|infix|infixl|infixr|prefix|postfix|"
    r"run_cmd|run_tac|run_elab|run_meta|initialize|builtin_initialize|instance|attribute|"
    r"partial|private|local|scoped|namespace|section|end|universe|variable|export|IO|System|"
    r"Lean|native|simproc|dsimproc)\b"
    # any word containing elab (by_elab, elab_rules, run_elab: `\belab\b` misses them, `_` is a word character);
    # backtick name literals and quotations are metaprogramming, which a proof body never needs (OT-1861)
    r"|\w*elab\w*|`|#|@\[|\$|«|»")


def strip_comments(source):
    out, i, depth = [], 0, 0
    while i < len(source):
        if source.startswith("/-", i):
            depth += 1
            i += 2
        elif depth and source.startswith("-/", i):
            depth -= 1
            i += 2
        elif depth:
            i += 1
        elif source.startswith("--", i):
            j = source.find("\n", i)
            i = len(source) if j == -1 else j
            out.append("\n")
        else:
            out.append(source[i])
            i += 1
    if depth:
        raise ValueError("Unclosed Lean comment")
    return "".join(out)


def validate(source, required):
    if not isinstance(source, str) or not 0 < len(source.encode()) <= 24000:
        raise ValueError("Lean body must contain at most 24000 UTF-8 bytes")
    code = strip_comments(source)
    if '"' in code:
        raise ValueError("Put prose in comments; executable strings are outside this contract")
    code = re.sub(r"^\s*set_option (maxRecDepth|maxHeartbeats) \d+\s*$", "", code, flags=re.M)
    if re.search(r"\bset_option\b", code):
        raise ValueError("Only maxRecDepth/maxHeartbeats options are available")
    if "VAS_" in code:
        raise ValueError("Names containing VAS_ are reserved for the checker's own report")
    bad = FORBIDDEN.search(code)
    if bad:
        raise ValueError(f"Outside the restricted Lean contract: {bad.group()}")
    if re.search(r"\b(?:def|abbrev|theorem|lemma|structure|inductive|class)\s+[^\s:(]+\.", code):
        raise ValueError("Declare plain top-level names; namespaces are outside this contract")
    theorems = re.findall(r"^\s*(?:theorem|lemma)\s+([A-Za-z_][A-Za-z_0-9']*)", code, re.M)
    missing = [n for n in required if n not in theorems]
    if missing:
        raise ValueError(f"Missing required theorems: {missing}")
    if re.search(r"\baxiom\b(?!\s+[A-Za-z_][A-Za-z_0-9']*\s*[:({\[])", code):
        raise ValueError("Declare an added assumption as `axiom name : statement` at the start of a line")
    return theorems


# Lean itself lists what the proof adds: every axiom declared in the file and every sorry (by its elaborated goal with
# the hypotheses in scope), each marked used when a conclusion theorem reaches it. Read from the checked kernel
# environment, as #print axioms does. Never part of an agent body (run_cmd is outside the contract).
LISTER = """
/-- true if `sorryAx` occurs anywhere other than as the head of an application that states its goal -/
private partial def VAS_unstated : Lean.Expr → Bool
  | e@(.app ..) =>
    let f := e.getAppFn
    (if f.isConstOf ``sorryAx then false else VAS_unstated f) || e.getAppArgs.any VAS_unstated
  | .const n _ => n == ``sorryAx
  | .lam _ t b _ | .forallE _ t b _ => VAS_unstated t || VAS_unstated b
  | .letE _ t v b _ => VAS_unstated t || VAS_unstated v || VAS_unstated b
  | .mdata _ b | .proj _ _ b => VAS_unstated b
  | _ => false

set_option format.width 100000 in
set_option pp.deepTerms true in
set_option pp.proofs true in
set_option pp.maxSteps 100000000 in
open Lean Elab Command Meta in
run_cmd do
  let kenv := (← getEnv).checked.get
  let locals := kenv.constants.map₂.toList
  let localSet : NameSet := locals.foldl (fun s (n, _) => s.insert n) {}
  let exprsOf (ci : ConstantInfo) : Array Expr :=
    #[ci.type] ++ (match ci with
      | .defnInfo v => #[v.value] | .thmInfo v => #[v.value] | .opaqueInfo v => #[v.value] | _ => #[])
  let mut used : NameSet := {}
  let mut todo : List Name := ROOTS
  while !todo.isEmpty do
    let n := todo.head!
    todo := todo.tail!
    if used.contains n then continue
    used := used.insert n
    if let some ci := kenv.find? n then
      for e in exprsOf ci do
        for c in e.getUsedConstants do
          if localSet.contains c && !used.contains c then todo := c :: todo
  for (n, ci) in locals do
    if let .axiomInfo _ := ci then
      logInfo m!"VAS_AXIOM {n} used={used.contains n} : {← liftTermElabM <| ppExpr ci.type} VAS_END"
    -- every declaration kind, type and value: a gap may sit in an axiom's type as well as in a proof
    for e in exprsOf ci do
      -- hasSorry is cached and linear; VAS_unstated walks the term as a tree, exponential on shared proofs
      if e.hasSorry && VAS_unstated e then
        logInfo m!"VAS_GAP {n} used={used.contains n} : (sorry with no stated goal: it can assert anything) VAS_END"
        logInfo m!"VAS_UNSTATED {n} used={used.contains n}"
    if (exprsOf ci).any (·.hasSorry) then
      let seen ← IO.mkRef ({} : Std.HashSet String)
      liftTermElabM do
        for e in exprsOf ci do
          forEachExpr' e fun sub => do
            if sub.isAppOf ``sorryAx && sub.getAppNumArgs ≥ 1 then
              let mut t ← instantiateMVars (sub.getArg! 0)
              if t.isForall && t.bindingDomain!.isConstOf ``Lean.Name then t := t.bindingBody!
              let hyps ← (← getLCtx).foldlM (init := m!"") fun acc d => do
                if d.isImplementationDetail then return acc
                match d.value? with
                | some v => return acc ++ m!"({d.userName} : {← ppExpr d.type} := {← ppExpr v}) "
                | none => return acc ++ m!"({d.userName} : {← ppExpr d.type}) "
              let line ← (m!"VAS_GAP {n} used={used.contains n} : {hyps}⊢ {← ppExpr t} VAS_END").toString
              unless (← seen.get).contains line do
                seen.modify (·.insert line)
                logInfo line
            return true
  logInfo "VAS_LISTED"
"""


def listed(text):
    """Parse the lister's output into added_assumptions entries; None if the lister did not finish."""
    if not re.search(r"^VAS_LISTED\s*$", text, re.M):  # the marker line itself, not a substring of other output
        return None
    out = []
    for kind, name, used, stmt in re.findall(r"VAS_(AXIOM|GAP) (\S+) used=(true|false) : (.*?) VAS_END", text, re.S):
        out.append({"kind": kind.lower(), "in" if kind == "GAP" else "name": name, "used": used == "true",
                    "statement": " ".join(stmt.split())})
    return out
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/Model.lean <<'EOF'\nimport Mathlib.Data.Real.Basic\nimport Mathlib.Tactic\n\n/- A schedule: water temperature x just before salt addition (deg C),\n   elapsed addition time a (s), mixed temperature z (deg C), and first\n   arrival at the final solution boiling temperature at time t (s). -/\nstructure HeatingRun where\n  x : ℝ\n  a : ℝ\n  z : ℝ\n  t : ℝ\n\n/- C is water plus pot heat capacity, S the added salt's effective heat\n   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),\n   Ts the salt's initial temperature, B the final boiling temperature.\n   P and Q are constant NET heating powers before and after addition (W).\n   The three equalities express heating, instantaneous mixing/dissolution,\n   and subsequent heating, respectively. No evaporation or phase change\n   occurs before the endpoint; that is an applicability assumption.\n   The inequalities ensure forward times and heating to the endpoint. -/\ndef HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=\n  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧\n  P * r.a = C * (r.x - 20) ∧\n  (C + S) * r.z = C * r.x + S * Ts - H ∧\n  Q * (r.t - r.a) = (C + S) * (B - r.z)\n\n/- Eliminate the unobserved mixing temperature and addition time from\n   energy conservation; this is derived, not an assumed timing formula. -/\nlemma time_from_balance :\n    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),\n    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →\n    r.t = C * (r.x - 20) / P +\n      ((C + S) * B - C * r.x - S * Ts + H) / Q := by\n  intro C S H Ts B P Q r hP hQ hr\n  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩\n  apply (eq_div_iff (ne_of_gt hQ)).mp |>.mpr\n  field_simp\nEOF\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'\ns=open(p).read(); s=s[:s.index('  apply (eq_div_iff')]+'''  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by\n    nlinarith [hmix, hpost]\n  field_simp\n  nlinarith [congrArg (fun v : ℝ => P * v) he,\n    congrArg (fun v : ℝ => Q * v) hpre]\n\n/- Scientific conclusion: for two admissible addition temperatures x<y,\n   later addition takes longer exactly when the salted stage heats faster;\n   it takes less time exactly when that stage heats slower. Equal powers\n   give equal completion times and the stated common energy/power time.\n   All parameters are left symbolic: the observations do not fit them. -/\ntheorem addition_timing_answer :\n    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),\n    0 < C → 0 ≤ S → 0 < P → 0 < Q →\n    HeatBalance C S H Ts B P Q r →\n    HeatBalance C S H Ts B P Q s → r.x < s.x →\n    (r.t < s.t ↔ P < Q) ∧\n    (s.t < r.t ↔ Q < P) ∧\n    (s.t = r.t ↔ Q = P) ∧\n    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by\n  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy\n  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)\n  have hpq : 0 < P * Q := mul_pos hP hQ\n  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by\n    rw [time_from_balance C S H Ts B P Q s hP hQ hs,\n      time_from_balance C S H Ts B P Q r hP hQ hr]\n    field_simp\n    <;> ring\n  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by\n    calc\n      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=\n        (mul_pos_iff_of_pos_left hpq).symm\n      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]\n      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd\n  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by\n    nlinarith [hid]\n  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by\n    calc\n      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=\n        (mul_pos_iff_of_pos_left hpq).symm\n      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]\n      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd\n  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),\n    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩\n  · constructor\n    · intro ht\n      have hz : C * (s.x - r.x) * (Q - P) = 0 := by\n        rw [← hid, ht]\n        ring\n      rcases mul_eq_zero.mp hz with hz | hz\n      · exact False.elim ((ne_of_gt hd) hz)\n      · linarith\n    · intro heq\n      have hz : P * Q * (s.t - r.t) = 0 := by\n        rw [hid, heq]\n        ring\n      rcases mul_eq_zero.mp hz with hz | hz\n      · exact False.elim ((ne_of_gt hpq) hz)\n      · linarith\n  · intro heq\n    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]\n    field_simp\n    <;> ring\n'''; open(p,'w').write(s)\nPY\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'; s=open(p).read().replace('field_simp\\\\n','field_simp [ne_of_gt hP, ne_of_gt hQ]\\\\n'); open(p,'w').write(s)\nPY\ncat > /work/report.txt <<'EOF'\nAnswer and practical interpretation\n\nThe supplied information does not identify a best salt-addition temperature or heating time. Under a well-mixed, constant-net-power model with negligible evaporation and instantaneous dissolution, every admissible addition time gives the SAME time to the final salted solution's boiling point. Adding the salt now at 20 degrees C is therefore as fast as waiting in that model. This is a conditional tie, not evidence that immediate addition is the unique real-world optimum. There is no supported numerical waiting time.\n\nWaiting until the unsalted water boils does not avoid heating the salt, supplying any endothermic dissolution energy, or reaching the solution's higher boiling temperature. The endpoint here is arrival of the mixed salted liquid at its equilibrium boiling temperature, not a momentary burst of bubbles. Do not extend this model to prolonged unsalted boiling: evaporation then changes both mass and concentration.\n\nSupplied information\n\nThe user supplies 1 litre of water initially at 20 degrees C in a pot being heated by a stove. The salt quantity, pot, heater and room conditions are unspecified. No temperature-versus-time observations, power measurements, pressure, salt temperature, or dissolution observations are supplied. There is no dataset from which to estimate heating parameters. The volume does not specify the combined water-plus-pot heat capacity; it is retained as context rather than converted to an invented exact mass or capacity.\n\nAdditional modeling choices and their reasons\n\nUse deterministic lumped calorimetry, not Bayesian inference: there are no noisy measurements requiring a likelihood or a prior. Interpret salt as a soluble nonvolatile cooking salt, completely dissolved at the endpoint. Hold its amount, starting temperature, pressure, and final composition fixed when comparing schedules. The final boiling temperature B is accordingly fixed across those comparisons but remains unknown; do not assume B = 100 degrees C. Boiling-point elevation motivates this distinction, but its numerical size is not needed or inferred.\n\nApproximate water and pot by one uniform temperature and constant combined heat capacity C > 0. Approximate the added salt's sensible heat capacity contribution by S >= 0, so the salted system has capacity C+S. This additive, temperature-independent capacity is a simplifying choice, not an exact property of brine. Represent the fixed dissolution energy cost by H, positive for endothermic dissolution. Allow H to remain symbolic, including either sign; do not insert an unmeasured enthalpy. The salt starts at Ts. Heat exchanged during instantaneous mixing is internal; H is paid by the sensible thermal energy. No loss of material, latent heat expenditure, mixing delay, stirring work, spillage or stove interruption is included. Treat the pot as initially at the water temperature. Only schedules with no phase change before the endpoint fall within the model's physical applicability; in particular the pre-addition temperature must not exceed the pure-water boiling temperature at the actual pressure. The Lean inequalities alone do not encode that pressure-dependent restriction.\n\nFirst allow constant positive net powers P before addition and Q afterward. Net means energy actually entering the modeled thermal system, after heat loss. Treating either as constant is a chosen approximation; the stove setting alone does not imply constant net power. This family exposes dependence on an unidentified parameter rather than inferring that salt necessarily changes heating power. Its equal-power special case P=Q is the simple negligible-loss, unchanged-heater baseline. Actual temperature-dependent heat losses, evaporation, variable heat capacities and dissolution kinetics require a richer model or measurements. The theorem does not choose an optimum for those systems.\n\nDefinitions, equations, and inference\n\nThe only public definitions are HeatingRun (x: pre-addition temperature, a: elapsed addition time, z: post-mixing temperature, t: elapsed boiling time) and HeatBalance. Times are in seconds, temperatures in degrees C, capacities in J/K, energies in J, powers in W. A common arbitrary sensible-enthalpy reference permits using C*x; only differences enter the balances.\n\nHeatBalance says 20 <= x, 0 <= a <= t, z <= B, and:\n  P*a = C*(x-20)                       [heating before addition]\n  (C+S)*z = C*x + S*Ts - H             [mixing and dissolution]\n  Q*(t-a) = (C+S)*(B-z)                [heating after addition]\nThese are physical assumptions, not supplied observations. For positive capacities and powers, linear heating between the endpoints is monotone, so the last equation corresponds to first arrival at B in this ideal model.\n\nThe intermediate lemma time_from_balance eliminates both a and z using these balances and proves:\n  t(x) = C*(x-20)/P + ((C+S)*B-C*x-S*Ts+H)/Q.\nThus salt heating and dissolution have not been omitted or assumed to cancel independently of the model. For two runs at x<y it derives:\n  P*Q*(t(y)-t(x)) = C*(y-x)*(Q-P).\n\nThe single final theorem addition_timing_answer proves all of the following, conditional on the stated balances and positive C,P,Q with S>=0:\n  earlier addition finishes sooner iff Q>P;\n  later addition finishes sooner iff Q<P;\n  completion times are equal iff Q=P;\n  when Q=P, t = ((C+S)*B-C*20-S*Ts+H)/P.\nFor the unequal-power model, these pairwise comparisons imply preference for the earliest or latest feasible addition, respectively; no feasible upper addition temperature or time is numerically specified here. In the equal-power case all feasible addition temperatures tie. Addition time and pre-addition temperature correspond through a=C*(x-20)/P, with P itself unidentified. Nothing supplied fixes the sign of Q-P or the common time, so this analysis cannot support a universal real-world optimum or a number of seconds. These are conditional predictions, not parameter estimates or performed experiments.\n\nCompact review boundary\n\nSupplied: 1 litre initially at 20 degrees C; heating on a stove; unspecified salt and apparatus.\nIndependent choices: fixed final composition/pressure; lumped constant additive capacities; fixed salt initial temperature and dissolution cost; instantaneous complete mixing/dissolution; no evaporation or other phase changes before endpoint; positive stagewise constant net powers and unchanged parameters across schedules. Equal net powers is an additional special-case assumption, not a consequence of the user facts.\nNecessary definitions: HeatingRun and HeatBalance, exactly as translated above.\nProved: energy-balance elimination, temperature-dependent time difference, and the comparison/equal-power answer. No added axioms or sorry are intended. The theorem does not prove that the chosen physical approximations hold in the user's kitchen, that either power relation actually occurs there, or that the data estimate any of these parameters. No human approval is claimed.\n\nSources and limitations\n\nOpenStax, University Physics Volume 2, section 1.4, Heat Transfer, Specific Heat, and Calorimetry:\nhttps://openstax.org/books/university-physics-volume-2/pages/1-4-heat-transfer-specific-heat-and-calorimetry\nConsulted for general calorimetry and conservation-of-energy background. It motivates the lumped sensible-heat balance, not this pot's parameter values or the constancy of its net power.\n\nOpenStax, Chemistry 2e, section 11.4, Colligative Properties:\nhttps://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties\nConsulted for the vapor-pressure definition of boiling and solute-induced boiling-point elevation. No numerical dilute-solution formula or concentration is assumed in the proof.\n\nThese are general educational sources, not measurements of this system. Web consultation on 2026-11-16. No operator responses have been requested or incorporated. The formal check establishes only the mathematical implication from the explicit assumptions; physical applicability and the adequacy of the scientific answer remain for human review.\nEOF\npython - <<'PY'\nimport json\nc={\n 'proof_file':'Model.lean', 'narrative_file':'report.txt',\n 'conclusions':{'answer':'addition_timing_answer'},\n 'user_facts':['1 litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.', 'Salt will be added; its amount and the pot, heater and room conditions are unspecified.'],\n 'model_choices':['Deterministic lumped calorimetry with constant water-plus-pot capacity C>0 and additive salt contribution S>=0; pot initially at 20 C.', 'Compare fixed salt amount, salt initial temperature Ts, dissolution energy H, pressure and final boiling temperature B across schedules; all remain symbolic and unestimated.', 'Instantaneous complete dissolution and mixing; no material loss, evaporation, phase change before endpoint, mixing delay or stove interruption. Only physically feasible pre-boiling addition schedules apply.', 'Constant positive net powers P before salting and Q afterward, identical across compared schedules; equal powers is a conditional special case, not inferred from the data.'],\n 'sources':['https://openstax.org/books/university-physics-volume-2/pages/1-4-heat-transfer-specific-heat-and-calorimetry','https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties'],\n 'incorporated_inputs':[],\n 'proof_scope':'Derives total boiling time from preheating, mixing/dissolution and postheating energy balances. Proves the exact earlier/later/equal timing comparison according to the sign of Q-P, and the temperature-independent time for equal net powers. Does not estimate any physical parameters or establish model applicability, a unique real-world optimum, or human approval.'}\nopen('/work/candidate.json','w').write(json.dumps(c,indent=2)+'\\\\n')\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json\""
}
shell output · exit 1 · failed
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:25:46.169042+00:00",
  "lean_exit": 1,
  "error": "Lean, kernel recheck or axiom audit failed; see lean.log"
}
shell input
{
  "command": "/usr/bin/bash -lc 'find /work -maxdepth 3 -type f; cat /work/lean.log'"
}
shell output · exit 1 · failed
/work/report.txt
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-report.txt
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-candidate.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean
/work/Model.lean
/work/candidate.json
cat: /work/lean.log: No such file or directory
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log'"
}
shell output · exit 0
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean:1:0: error: object file '/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic.olean' of module Mathlib.Tactic does not exist
shell input
{
  "command": "/usr/bin/bash -lc 'ls /harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic | head -60; ls /harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic*'"
}
shell output · exit 0
Abel.ilean
Abel.ilean.hash
Abel.ir
Abel.ir.hash
Abel.ir.sig
Abel.ir.sig.hash
Abel.olean
Abel.olean.hash
Abel.olean.private
Abel.olean.private.hash
Abel.olean.server
Abel.olean.server.hash
Abel.trace
AdaptationNote.ilean
AdaptationNote.ilean.hash
AdaptationNote.ir
AdaptationNote.ir.hash
AdaptationNote.ir.sig
AdaptationNote.ir.sig.hash
AdaptationNote.olean
AdaptationNote.olean.hash
AdaptationNote.olean.private
AdaptationNote.olean.private.hash
AdaptationNote.olean.server
AdaptationNote.olean.server.hash
AdaptationNote.trace
AddGroup.ilean
AddGroup.ilean.hash
AddGroup.ir
AddGroup.ir.hash
AddGroup.ir.sig
AddGroup.ir.sig.hash
AddGroup.olean
AddGroup.olean.hash
AddGroup.olean.private
AddGroup.olean.private.hash
AddGroup.olean.server
AddGroup.olean.server.hash
AddGroup.trace
Algebra
Algebraize.ilean
Algebraize.ilean.hash
Algebraize.ir
Algebraize.ir.hash
Algebraize.ir.sig
Algebraize.ir.sig.hash
Algebraize.olean
Algebraize.olean.hash
Algebraize.olean.private
Algebraize.olean.private.hash
Algebraize.olean.server
Algebraize.olean.server.hash
Algebraize.trace
ApplyAt.ilean
ApplyAt.ilean.hash
ApplyAt.ir
ApplyAt.ir.hash
ApplyAt.ir.sig
ApplyAt.ir.sig.hash
ApplyAt.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.ilean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.ilean.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.ir
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.ir.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.ir.sig
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.ir.sig.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.olean.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.olean.private
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.olean.private.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.olean.server
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.olean.server.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Real/Basic.trace
assistant
The energy-balance derivation gives the expected tie when net heating power is unchanged. It also gives a precise conditional result when power differs: early addition wins if net power is higher after salting, and later addition wins if it is lower. The first check failed because the installed library lacks the broad tactic import; I’m replacing it with specific imports and rerunning.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'; s=open(p).read().replace('import Mathlib.Tactic\\\\n','import Mathlib.Tactic.Linarith\\\\nimport Mathlib.Tactic.FieldSimp\\\\nimport Mathlib.Tactic.Ring\\\\n'); open(p,'w').write(s)\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json\""
}
shell output · exit 1 · failed
{
 "file": "/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean",
 "conclusions": [
  "addition_timing_answer"
 ],
 "lean_exit": 0,
 "ok": false,
 "compiles_alone": true,
 "faithful": {
  "addition_timing_answer": false
 },
 "assumption_declarations": [
  "HeatingRun",
  "HeatBalance"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "addition_timing_answer": {
   "original_sha256": "ba12cbdde9a2eaa4feecd8115fdfb74571f12fb6c688ea0c72623b02e2b8a47c",
   "extracted_sha256": "d6987730ba2db2abbac7b4f5f88e2d1dfbe37ba20b41e95b7d2f4a719a169535"
  }
 },
 "dependency_faithful": {
  "HeatingRun": true,
  "HeatingRun.mk": true,
  "HeatBalance": true,
  "HeatBalance._proof_1": true,
  "HeatingRun.x": true,
  "HeatingRun.a": true,
  "HeatingRun.t": true,
  "HeatingRun.z": true
 },
 "dependency_identities": {
  "HeatingRun": {
   "original_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e",
   "extracted_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e"
  },
  "HeatingRun.mk": {
   "original_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429",
   "extracted_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429"
  },
  "HeatBalance": {
   "original_sha256": "839a8d3a6c19361f87307a620f90ddebc95775d96889c0274dbd98e8334ae9f4",
   "extracted_sha256": "839a8d3a6c19361f87307a620f90ddebc95775d96889c0274dbd98e8334ae9f4"
  },
  "HeatBalance._proof_1": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "HeatingRun.x": {
   "original_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4",
   "extracted_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4"
  },
  "HeatingRun.a": {
   "original_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8",
   "extracted_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8"
  },
  "HeatingRun.t": {
   "original_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4",
   "extracted_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4"
  },
  "HeatingRun.z": {
   "original_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423",
   "extracted_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "addition_timing_answer": "\u2200 (C S H Ts B P Q : \u211d) (r s : HeatingRun), 0 < C \u2192 0 \u2264 S \u2192 0 < P \u2192 0 < Q \u2192 HeatBalance C S H Ts B P Q r \u2192 HeatBalance C S H Ts B P Q s \u2192 r.x < s.x \u2192 (r.t < s.t \u2194 P < Q) \u2227 (s.t < r.t \u2194 Q < P) \u2227 (s.t = r.t \u2194 Q = P) \u2227 (Q = P \u2192 r.t = ((C + S) * B - C * 20 - S * Ts + H) / P)"
 },
 "extracted_file": "/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean",
 "errors": []
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:26:03.961421+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
shell input
{
  "command": "/usr/bin/bash -lc \"find /work/checks -name lean.log -exec sh -c 'echo \\\"\"'$1\"; tail -45 \"$1\"'\"' sh {} \\\\;\""
}
shell output · exit 0
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean:1:0: error: object file '/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic.olean' of module Mathlib.Tactic does not exist
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/lean.log
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean:1:0: warning: 
'Mathlib.Data.Real.Basic' has been deprecated: please replace this import by

import Mathlib.Basic.Real.Basic
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean:65:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean:100:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean:65:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean:100:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
'addition_timing_answer' depends on axioms: [propext, Classical.choice, Quot.sound]
VAS_LISTED

leanchecker exit 0

shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean; ls /work/checks/f49ea96bd5de45babf8f3c699ba15e09'"
}
shell output · exit 0
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)


/-! Conclusions (statements of the proved theorems). -/
def conclusion_addition_timing_answer : Prop := ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun), 0 < C → 0 ≤ S → 0 < P → 0 < Q → HeatBalance C S H Ts B P Q r → HeatBalance C S H Ts B P Q s → r.x < s.x → (r.t < s.t ↔ P < Q) ∧ (s.t < r.t ↔ Q < P) ∧ (s.t = r.t ↔ Q = P) ∧ (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P)
Checked.lean
extracted.json
extracted.lean
lean.log
submitted-candidate.json
submitted-report.txt
submitted.lean
verdict.json
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '1,240p' /harness/src/vcs_extract.py\""
}
shell output · exit 0
"""Extract statement dependencies and conclusions; independently compile and compare."""
import hashlib
import json
import os
from pathlib import Path
import re
import subprocess
import tempfile
import sys

import click

ROOT = Path(__file__).resolve().parents[1]
from vcs_lean import LEAN, LEANCHECKER, LISTER, listed  # noqa: E402

# Display text omits implicit arguments, types and sometimes whole subterms.
# Compare the complete kernel expressions instead. Binder names and metadata do
# not affect meaning; remove them so source positions and fresh binder names do
# not make an otherwise identical extraction fail. All constants, universe
# levels, implicit arguments and binder information remain in the identity.
IDENTITY = """
private partial def VAS_identityExpr : Lean.Expr → Lean.Expr
  | .mdata _ value => VAS_identityExpr value
  | .app fn arg => .app (VAS_identityExpr fn) (VAS_identityExpr arg)
  | .lam _ typ body info => .lam .anonymous (VAS_identityExpr typ) (VAS_identityExpr body) info
  | .forallE _ typ body info => .forallE .anonymous (VAS_identityExpr typ) (VAS_identityExpr body) info
  | .letE _ typ value body flag => .letE .anonymous (VAS_identityExpr typ) (VAS_identityExpr value) (VAS_identityExpr body) flag
  | .proj owner idx value => .proj owner idx (VAS_identityExpr value)
  | value => value

private def VAS_declarationIdentity (ci : Lean.ConstantInfo) : String :=
  let kind := match ci with
    | .axiomInfo _ => "axiom"
    | .defnInfo _ => "definition"
    | .thmInfo _ => "theorem"
    | .opaqueInfo _ => "opaque"
    | .quotInfo _ => "quotient"
    | .inductInfo info => s!"inductive {info.numParams} {info.numIndices} {reprStr info.ctors}"
    | .ctorInfo info => s!"constructor {info.induct} {info.cidx} {info.numParams} {info.numFields}"
    | .recInfo info => s!"recursor {info.numParams} {info.numIndices} {info.numMotives} {info.numMinors}"
  let value := match ci.value? with
    | some body => reprStr (VAS_identityExpr body)
    | none => "no value"
  s!"{kind}|levels={reprStr ci.levelParams}|type={reprStr (VAS_identityExpr ci.type)}|value={value}"
"""

REACH = """
open Lean Elab Command Meta in
run_cmd do
  let kenv := (← getEnv).checked.get
  let localSet : NameSet := kenv.constants.map₂.toList.foldl (fun s (n, _) => s.insert n) {}
  -- statements only: from each conclusion's type, through definitions' types and values
  let mut seen : NameSet := {}
  let mut todo : List Name := []
  for t in TARGETS do
    let some ci := kenv.find? t | throwError m!"no theorem {t}"
    todo := ci.type.getUsedConstants.toList ++ todo
    logInfo m!"VAS_CONCLUSION {t} : {← liftTermElabM <| ppExpr ci.type} VAS_END"
    logInfo m!"VAS_ORIGINAL_IDENTITY {t} : {reprStr (VAS_identityExpr ci.type)} VAS_END"
  while !todo.isEmpty do
    let n := todo.head!
    todo := todo.tail!
    if seen.contains n || !localSet.contains n then continue
    seen := seen.insert n
    let some ci := kenv.find? n | continue
    logInfo m!"VAS_DEPENDENCY_IDENTITY {n} : {VAS_declarationIdentity ci} VAS_END"
    let more := ci.type.getUsedConstants ++ (match ci with
      | .defnInfo v => v.value.getUsedConstants | .thmInfo v => v.value.getUsedConstants
      | .opaqueInfo v => v.value.getUsedConstants
      | .inductInfo v => v.ctors.toArray | .ctorInfo v => #[v.induct] | _ => #[])
    todo := more.toList ++ todo
    -- auxiliary constants (matchers, constructors, projections, equation lemmas) map to the nearest ancestor
    -- whose source range Lean recorded
    let mut m := n
    let mut r ← findDeclarationRanges? m
    while r.isNone && !m.isAnonymous do
      m := m.getPrefix
      r ← findDeclarationRanges? m
    match r with
    | some rg => logInfo m!"VAS_DECL {m} {rg.range.pos.line} {rg.range.endPos.line}"
    | none => logInfo m!"VAS_UNRANGED {n}"
  logInfo "VAS_REACHED"
"""

COMPARE = """
set_option format.width 100000 in
open Lean Elab Command Meta in
run_cmd do
  for n in NAMES do
    let some ci := (← getEnv).find? n | throwError m!"no {n}"
    let some v := ci.value? | throwError m!"no value {n}"
    logInfo m!"VAS_EXTRACTED {n} : {← liftTermElabM <| ppExpr v} VAS_END"
    logInfo m!"VAS_EXTRACTED_IDENTITY {n} : {reprStr (VAS_identityExpr v)} VAS_END"
  for n in DEPENDENCIES do
    let some ci := (← getEnv).find? n | throwError m!"missing extracted dependency {n}"
    logInfo m!"VAS_EXTRACTED_DEPENDENCY_IDENTITY {n} : {VAS_declarationIdentity ci} VAS_END"
"""


def run_lean(path):
    """Lean, then leanchecker on the compiled module (OT-1861): a nonzero status if either fails."""
    libs = sorted((ROOT / ".lake/packages").glob("*/.lake/build/lib/lean"))
    env = dict(os.environ, LEAN_PATH=":".join(map(str, libs)), LEAN_NUM_THREADS="1")
    with tempfile.TemporaryDirectory(prefix="vcs-olean-") as build:
        r = subprocess.run([LEAN, "-j1", f"--root={Path(path).resolve().parent}", "-o", str(Path(build) / "VasExtract.olean"), str(path)], cwd=ROOT,
                           env=env, capture_output=True, text=True, timeout=900)
        if r.returncode != 0:
            return r.returncode, r.stdout + r.stderr
        c = subprocess.run([LEANCHECKER, "VasExtract"], cwd=ROOT, capture_output=True, text=True, timeout=900,
                           env=dict(env, LEAN_PATH=env["LEAN_PATH"] + ":" + build,
                                    PATH=str(Path(LEAN).parent) + ":" + env.get("PATH", "")))
        note = f"\nleanchecker exit {c.returncode}\n{(c.stdout + c.stderr)[-1500:]}\n"
        return (0 if c.returncode == 0 else 10), r.stdout + r.stderr + note


def expression_identities(text, marker):
    """Read complete expression records; duplicate/missing records fail closed."""
    records = re.findall(r"^" + re.escape(marker) + r" (\S+) : (.*?) VAS_END", text, re.M | re.S)
    result = {}
    for name, value in records:
        if name in result:
            raise ValueError(f"duplicate expression identity for {name}")
        result[name] = " ".join(value.split())
    return result


def statement_text(lines, start, name):
    """The source of theorem `name`'s statement: from after `name :` to the `:=` that opens its proof."""
    text = "\n".join(lines[start - 1:])
    m = re.match(r"\s*(?:theorem|lemma)\s+" + re.escape(name) + r"\s*:(.*?):=", text, re.S)
    if not m:
        raise ValueError(f"cannot read the statement of {name}")
    return " ".join(m.group(1).split())


@click.command()
@click.argument("lean_file", type=click.Path(exists=True, dir_okay=False))
@click.option("--theorem", "theorems", multiple=True, required=True, help="a conclusion theorem (repeatable)")
@click.option("--out", "out_stem", required=True, help="output stem: writes <out>.lean and <out>.json")
def main(lean_file, theorems, out_stem):
    src = Path(lean_file).read_text()
    lines = src.splitlines()
    out = Path(out_stem)
    probe = out.with_name(out.name + ".probe.lean")
    targets = "[" + ", ".join(f"``{t}" for t in theorems) + "]"
    body = re.sub(r"(?m)^#print axioms.*\n?", "", src)
    # a file written by the current checker already ends with its own LISTER; drop it, the probe appends one
    head = next(ln for ln in LISTER.splitlines() if ln.strip())
    if head in body:
        body = body[:body.index(head)]
    probe.write_text(body + "\nset_option format.width 100000\n" + IDENTITY + REACH.replace("TARGETS", targets)
                     + LISTER.replace("ROOTS", targets))
    status, text = run_lean(probe)
    report = {"file": lean_file, "conclusions": list(theorems), "lean_exit": status}
    if status != 0 or "VAS_REACHED" not in text:
        report |= {"ok": False, "error": "the source did not compile with the extractor",
                   "errors": [ln for ln in text.splitlines() if ": error" in ln][:5]}
        print(json.dumps(report, indent=1))
        sys.exit(1)
    decls = {}
    for name, a, b in re.findall(r"VAS_DECL (\S+) (\d+) (\d+)", text):
        decls[name] = (int(a), int(b))
    unranged = re.findall(r"VAS_UNRANGED (\S+)", text)
    concl = dict(re.findall(r"VAS_CONCLUSION (\S+) : (.*?) VAS_END", text, re.S))
    original_identities = expression_identities(text, "VAS_ORIGINAL_IDENTITY")
    dependency_identities = expression_identities(text, "VAS_DEPENDENCY_IDENTITY")
    added = [a for a in listed(text) or [] if a["used"]]
    # the extracted file: imports, then each assumption's source in file order, inside its namespace. A range
    # inside another one (a structure's fields and constructor) is part of it and is not copied twice.
    imports = [ln for ln in lines if ln.startswith("import ")]
    spans = sorted(set(decls.values()))
    keep = [s for s in spans if not any(o != s and o[0] <= s[0] and s[1] <= o[1] for o in spans)]
    for x, y in zip(keep, keep[1:]):
        if y[0] <= x[1]:
            raise ValueError(f"overlapping declaration ranges {x} and {y}")
    owner = {}
    for name, rng in decls.items():
        if rng in keep and (rng not in owner or len(name) < len(owner[rng])):
            owner[rng] = name
    head = re.compile(r"^\s*(?:@\[[^\]]*\]\s*)?(?:noncomputable\s+|private\s+|protected\s+)*"
                      r"(?:def|theorem|lemma|abbrev|structure|inductive|class|axiom|instance|opaque)\s+([^\s:({\[]+)")
    # top-level `open X` lines of the source go along, in file order, so names resolve as they did there
    opens = [(i + 1, i + 1) for i, ln in enumerate(lines)
             if re.match(r"open\s+[\w.]+(\s+[\w.]+)*\s*$", ln) and not any(a <= i + 1 <= b for a, b in keep)]
    parts, current = [], None
    for rng in sorted(keep + opens):
        a, b = rng
        if rng in opens and rng not in owner:
            if current:
                parts.append(f"end {current}\n")
                current = None
            parts.append(lines[a - 1])
            continue
        name = owner[rng]
        short = next((m.group(1) for ln in lines[a - 1:b] if (m := head.match(ln))), None)
        if short is None or not (name == short or name.endswith("." + short)):
            raise ValueError(f"cannot match the source of {name} at lines {a}-{b}")
        ns = name[: -len(short) - 1] if name != short else ""
        if ns != current:
            if current:
                parts.append(f"end {current}\n")
            if ns:
                parts.append(f"namespace {ns}")
            current = ns
        parts.append("\n".join(lines[a - 1:b]) + "\n")
    if current:
        parts.append(f"end {current}\n")
    starts = {}
    for t in theorems:
        m = re.search(r"(?m)^\s*(?:theorem|lemma)\s+" + re.escape(t) + r"\b", src)
        starts[t] = src[:m.start()].count("\n") + 1 if m else None
    stmts = {t: statement_text(lines, starts[t], t) for t in theorems}
    conclusions = "".join(f"def conclusion_{t} : Prop := {stmts[t]}\n" for t in theorems)
    extracted = ("\n".join(imports) + "\n\n" + "\n".join(parts) + "\n\n"
                 "/-! Conclusions (statements of the proved theorems). -/\n" + conclusions)
    out.with_suffix(".lean").write_text(extracted)
    # step 5: the extracted file compiles alone, and its conclusions are the proved statements
    check = out.with_name(out.name + ".check.lean")
    names = "[" + ", ".join(f"``conclusion_{t}" for t in theorems) + "]"
    dependencies = "[" + ", ".join(f"``{name}" for name in dependency_identities) + "]"
    check.write_text(extracted + IDENTITY + COMPARE.replace("NAMES", names).replace("DEPENDENCIES", dependencies))
    status2, text2 = run_lean(check)
    extracted_identities = expression_identities(text2, "VAS_EXTRACTED_IDENTITY")
    same = {t: bool(original_identities.get(t)) and
            original_identities[t] == extracted_identities.get("conclusion_" + t)
            for t in theorems}
    extracted_dependencies = expression_identities(text2, "VAS_EXTRACTED_DEPENDENCY_IDENTITY")
    dependencies_same = {name: value == extracted_dependencies.get(name)
                         for name, value in dependency_identities.items()}
    identity_hashes = {
        t: {"original_sha256": hashlib.sha256(original_identities[t].encode()).hexdigest()
            if t in original_identities else None,
            "extracted_sha256": hashlib.sha256(extracted_identities["conclusion_" + t].encode()).hexdigest()
            if "conclusion_" + t in extracted_identities else None}
        for t in theorems}
    dependency_hashes = {
        name: {"original_sha256": hashlib.sha256(value.encode()).hexdigest(),
               "extracted_sha256": hashlib.sha256(extracted_dependencies[name].encode()).hexdigest()
               if name in extracted_dependencies else None}
        for name, value in dependency_identities.items()}
shell input
{
  "command": "/usr/bin/bash -lc \"mkdir -p /work/diagnostics\ncat > /work/diagnostics/extraction_trace.py <<'PY'\nimport sys\nfrom pathlib import Path\nsys.path.insert(0, '/harness/src')\nimport vcs_extract\noriginal = vcs_extract.run_lean\ncounter = 0\ndef traced(path):\n    global counter\n    counter += 1\n    status, text = original(path)\n    Path(f'/work/diagnostics/extract-trace-{counter}.txt').write_text(text)\n    return status, text\nvcs_extract.run_lean = traced\nvcs_extract.main(args=['/work/Model.lean', '--theorem', 'addition_timing_answer', '--out', '/work/diagnostics/extracted'], standalone_mode=False)\nPY\npython /work/diagnostics/extraction_trace.py > /work/diagnostics/extraction-result.txt\""
}
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\nimport re,difflib\np=Path('/work/diagnostics')\na=p/'extract-trace-1.txt'; b=p/'extract-trace-2.txt'\nif a.exists() and b.exists():\n s=re.search(r'VAS_ORIGINAL_IDENTITY addition_timing_answer : (.*?) VAS_END', a.read_text(),re.S).group(1)\n t=re.search(r'VAS_EXTRACTED_IDENTITY conclusion_addition_timing_answer : (.*?) VAS_END', b.read_text(),re.S).group(1)\n for op,i,j,k,l in difflib.SequenceMatcher(None,s,t,autojunk=False).get_opcodes():\n  if op\"'!='\"'equal': print(op,repr(s[max(0,i-150):j+150]),repr(t[max(0,k-150):l+150]))\nelse: print('trace pending')\nPY\""
}
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\nimport re\np=Path('/work/diagnostics')\ns=re.search(r'VAS_ORIGINAL_IDENTITY addition_timing_answer : (.*?) VAS_END',(p/'extract-trace-1.txt').read_text(),re.S).group(1)\nt=re.search(r'VAS_EXTRACTED_IDENTITY conclusion_addition_timing_answer : (.*?) VAS_END',(p/'extract-trace-2.txt').read_text(),re.S).group(1)\ns=' '.join(s.split());t=' '.join(t.split())\nprint(len(s),len(t))\nfor i,(a,b) in enumerate(zip(s,t)):\n if a\"'!=b:\n  print('\"'First mismatch',i);print('ORIGINAL',s[max(0,i-250):i+500]);print('EXTRACTED',t[max(0,i-250):i+500]);break\nPY\""
}
shell output · exit 0
11015 10407
First mismatch 9426
ORIGINAL atVal 20))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instOfNatAtLeastTwo [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat []
EXTRACTED atVal 20))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instOfNatAtLeastTwo [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `HeatBalance._proof_1 [])))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HMul.hMul [Lean.Level.zero, Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instHMul [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.instMul []))) (Lean.Expr.bvar 15)) (Lean.Expr.bvar 13)))) (Lean.Expr.bvar 14))) (
assistant
Lean compiled the proof and the separate kernel check passed, but the extraction check failed: it compared two different internal representations of the numeral 20. I’m making the supplied initial temperature a named constant so the extracted statement preserves it exactly. The scientific model and conclusions remain unchanged.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean';s=open(p).read();s=s.replace('import Mathlib.Data.Real.Basic','import Mathlib.Basic.Real.Basic');s=s.replace('  20 ≤ r.x','  initialTemperature ≤ r.x').replace('r.x - 20','r.x - initialTemperature').replace('C * 20','C * initialTemperature'); idx=s.index('/- A schedule:');s=s[:idx]+'/- Supplied initial water temperature, in degrees Celsius. -/\\\\ndef initialTemperature : ℝ := 20\\\\n\\\\n'+s[idx:];open(p,'w').write(s)\np='/work/report.txt';s=open(p).read().replace('The only public definitions are HeatingRun','The public definitions are initialTemperature = 20 degrees C, HeatingRun').replace('Necessary definitions: HeatingRun and HeatBalance','Necessary definitions: initialTemperature, HeatingRun and HeatBalance');s+='\\\\nCheck history (raw traces retained under checks/ and diagnostics/): the first attempt failed because the umbrella Mathlib.Tactic module was unavailable; specific tactic imports fixed that. The second attempt compiled and passed kernel rechecking but failed exact extraction identity because a numeral instance proof was shared differently. Naming the supplied initial temperature explicitly addresses this representation issue without changing any physical assumptions or mathematical conclusions. The final check result is reported separately by the harness.\\\\n';open(p,'w').write(s)\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json\""
}
shell output · exit 0
{
 "file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean",
 "conclusions": [
  "addition_timing_answer"
 ],
 "lean_exit": 0,
 "ok": true,
 "compiles_alone": true,
 "faithful": {
  "addition_timing_answer": true
 },
 "assumption_declarations": [
  "initialTemperature",
  "HeatingRun",
  "HeatBalance"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "addition_timing_answer": {
   "original_sha256": "52894b2acf5bc09ce197451177b4618f9dbe95c87b766f295812a03077606c18",
   "extracted_sha256": "52894b2acf5bc09ce197451177b4618f9dbe95c87b766f295812a03077606c18"
  }
 },
 "dependency_faithful": {
  "HeatingRun": true,
  "HeatingRun.mk": true,
  "HeatBalance": true,
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "HeatingRun.x": true,
  "HeatingRun.a": true,
  "HeatingRun.t": true,
  "HeatingRun.z": true
 },
 "dependency_identities": {
  "HeatingRun": {
   "original_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e",
   "extracted_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e"
  },
  "HeatingRun.mk": {
   "original_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429",
   "extracted_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429"
  },
  "HeatBalance": {
   "original_sha256": "2e5a83c6c8dda7b7be5db30875038773a065f300c0e75be490f5e69df9d81069",
   "extracted_sha256": "2e5a83c6c8dda7b7be5db30875038773a065f300c0e75be490f5e69df9d81069"
  },
  "initialTemperature": {
   "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
   "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
  },
  "initialTemperature._proof_1": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "HeatingRun.x": {
   "original_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4",
   "extracted_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4"
  },
  "HeatingRun.a": {
   "original_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8",
   "extracted_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8"
  },
  "HeatingRun.t": {
   "original_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4",
   "extracted_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4"
  },
  "HeatingRun.z": {
   "original_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423",
   "extracted_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "addition_timing_answer": "\u2200 (C S H Ts B P Q : \u211d) (r s : HeatingRun), 0 < C \u2192 0 \u2264 S \u2192 0 < P \u2192 0 < Q \u2192 HeatBalance C S H Ts B P Q r \u2192 HeatBalance C S H Ts B P Q s \u2192 r.x < s.x \u2192 (r.t < s.t \u2194 P < Q) \u2227 (s.t < r.t \u2194 Q < P) \u2227 (s.t = r.t \u2194 Q = P) \u2227 (Q = P \u2192 r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P)"
 },
 "extracted_file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean",
 "errors": []
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-16T18:27:31.048579+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "HeatingRun",
      "HeatBalance"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "52894b2acf5bc09ce197451177b4618f9dbe95c87b766f295812a03077606c18",
        "extracted_sha256": "52894b2acf5bc09ce197451177b4618f9dbe95c87b766f295812a03077606c18"
      }
    },
    "dependency_faithful": {
      "HeatingRun": true,
      "HeatingRun.mk": true,
      "HeatBalance": true,
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "HeatingRun.x": true,
      "HeatingRun.a": true,
      "HeatingRun.t": true,
      "HeatingRun.z": true
    },
    "dependency_identities": {
      "HeatingRun": {
        "original_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e",
        "extracted_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e"
      },
      "HeatingRun.mk": {
        "original_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429",
        "extracted_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429"
      },
      "HeatBalance": {
        "original_sha256": "2e5a83c6c8dda7b7be5db30875038773a065f300c0e75be490f5e69df9d81069",
        "extracted_sha256": "2e5a83c6c8dda7b7be5db30875038773a065f300c0e75be490f5e69df9d81069"
      },
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "HeatingRun.x": {
        "original_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4",
        "extracted_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4"
      },
      "HeatingRun.a": {
        "original_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8",
        "extracted_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8"
      },
      "HeatingRun.t": {
        "original_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4",
        "extracted_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4"
      },
      "HeatingRun.z": {
        "original_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423",
        "extracted_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B P Q : \u211d) (r s : HeatingRun), 0 < C \u2192 0 \u2264 S \u2192 0 < P \u2192 0 < Q \u2192 HeatBalance C S H Ts B P Q r \u2192 HeatBalance C S H Ts B P Q s \u2192 r.x < s.x \u2192 (r.t < s.t \u2194 P < Q) \u2227 (s.t < r.t \u2194 Q < P) \u2227 (s.t = r.t \u2194 Q = P) \u2227 (Q = P \u2192 r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P)"
    },
    "extracted_file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
shell output · exit 0
delete '                                     (Lean.Expr.const `Real.instNatCast []))\n                                                              (Lean.Expr.app\n                                                                (Lean.Expr.app\n                                                                  (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat [])\n                                                                  (Lean.Expr.app\n                              ' '                                     (Lean.Expr.const `Real.instNatCast []))\n                                                              (Lean.Expr.const `HeatBalance._proof_1 []))))))\n                                                    (Lean.Expr.app\n                                              '
replace '                                                   (Lean.Expr.app\n                                                                  (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat [])\n                                                                  (Lean.Expr.app\n                                      ' '                              (Lean.Expr.const `Real.instNatCast []))\n                                                              (Lean.Expr.const `HeatBalance._proof_1 []))))))\n                                                    (Lean.Expr.app\n                                                      ('
insert '                                                (Lean.Expr.app\n                                                                  (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat [])\n                                                                  (Lean.Expr.app\n                                        ' '                          (Lean.Expr.const `Real.instNatCast []))\n                                                              (Lean.Expr.const `HeatBalance._proof_1 []))))))\n                                                    (Lean.Expr.app\n                                                      (Lean.Expr'
replace '                                               (Lean.Expr.app\n                                                                  (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat [])\n                                                                  (Lean.Expr.app\n                                                      ' '                  (Lean.Expr.const `Real.instNatCast []))\n                                                              (Lean.Expr.const `HeatBalance._proof_1 []))))))\n                                                    (Lean.Expr.app\n                                                      (Lean.Expr.app'
replace '                                 (Lean.Expr.app\n                                                                  (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat [])\n                                                                  (Lean.Expr.app\n                                                            ' '              (Lean.Expr.const `Real.instNatCast []))\n                                                              (Lean.Expr.const `HeatBalance._proof_1 []))))))\n                                                    (Lean.Expr.app\n                                                      (Lean.Expr.app\n '
replace '                           (Lean.Expr.app\n                                                                  (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat [])\n                                                                  (Lean.Expr.app\n                                                                ' '            (Lean.Expr.const `Real.instNatCast []))\n                                                              (Lean.Expr.const `HeatBalance._proof_1 []))))))\n                                                    (Lean.Expr.app\n                                                      (Lean.Expr.app\n    '
delete '                     (Lean.Expr.app\n                                                                  (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat [])\n                                                                  (Lean.Expr.app\n                                                                    (Lean.Expr.app\n                                                                      (Lean.Expr.app\n                                                                        (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero])\n                                                                        (Lean.Expr.const `Nat []))\n                                                                      (Lean.Expr.lit (Lean.Literal.natVal 19)))\n                                                                    (Lean.Expr.app\n                                                                      (Lean.Expr.const `instOfNatNat [])\n                                                                      (Lean.Expr.lit (Lean.Literal.natVal 19)))))\n                                                                (Lean.Expr.app\n                                                                  (Lean.Expr.const `Nat.instNeZeroSucc [])\n                                                                  (Lean.Expr.app\n                                                                    (Lean.Expr.app\n                                                                      (Lean.Expr.app\n                                                                        (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero])\n                                                                        (Lean.Expr.const `Nat []))\n                                                                      (Lean.Expr.lit (Lean.Literal.natVal 18)))\n                                                                    (Lean.Expr.app\n                                                                      (Lean.Expr.const `instOfNatNat [])\n                                                                      (Lean.Expr.lit (Lean.Literal.natVal 18)))))))))))\n                                                    (Lean.Expr.app\n                                                      (Lean.Expr.app\n       ' '       (Lean.Expr.const `Real.instNatCast []))\n                                                              (Lean.Expr.const `HeatBalance._proof_1 []))))))\n                                                    (Lean.Expr.app\n                                                      (Lean.Expr.app\n       '
shell input
{
  "command": "/usr/bin/bash -lc 'ps -eo pid,ppid,comm'"
}
shell output · exit 127 · failed
/usr/bin/bash: line 1: ps: command not found
assistant
**No unique best temperature or waiting time follows from the information supplied.**

Under the explicit idealization of constant net heating power, negligible evaporation, and instantaneous dissolution, **adding salt now at 20°C ties with adding it later**. The total heat requirement includes warming the salt, dissolution, and reaching the final solution’s boiling temperature.

If net heating power differs before and after salting, the conditional model favors earlier addition when power is higher afterward, and later addition when it is lower. Those powers are unspecified.

The Lean proof, independent extraction, and kernel checks passed, with no added axioms or `sorry`. Physical applicability remains for human review.

Files: [candidate](/work/candidate.json), [scientific report and sources](/work/report.txt), [Lean proof](/work/Model.lean).

Produced code

attempt-001/Model.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
attempt-001/extracted.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

def initialTemperature : ℝ := 20

structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)


/-! Conclusions (statements of the proved theorems). -/
def conclusion_addition_timing_answer : Prop := ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun), 0 < C → 0 ≤ S → 0 < P → 0 < Q → HeatBalance C S H Ts B P Q r → HeatBalance C S H Ts B P Q s → r.x < s.x → (r.t < s.t ↔ P < Q) ∧ (s.t < r.t ↔ Q < P) ∧ (s.t = r.t ↔ Q = P) ∧ (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P)
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring

Round 2

Messages

assistant
I’ll review the previous model and check feedback, then derive the before-and-after heating rates from explicit heat-transfer assumptions and use that relationship to analyze when to add the salt.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work'"
}
shell output · exit 0
total 56
drwxrwxr-x 4 1001 1001 4096 Nov 17 14:13 .
drwxr-xr-x 1 root root 4096 Nov 17 14:13 ..
-rw-r--r-- 1 1001 1001 4487 Nov 16 18:27 Model.lean
-rw-r--r-- 1 1001 1001 1710 Nov 16 18:25 candidate.json
drwxr-xr-x 5 1001 1001 4096 Nov 16 18:27 checks
drwxr-xr-x 2 1001 1001 4096 Nov 16 18:26 diagnostics
-rw------- 1 1001 1001  581 Nov 17 14:13 human-feedback.json
-rw------- 1 1001 1001 8367 Nov 16 18:28 last-review-packet.json
-rw-r--r-- 1 1001 1001 8704 Nov 16 18:27 report.txt
shell input
{
  "command": "/usr/bin/bash -lc 'cat Model.lean candidate.json report.txt human-feedback.json'"
}
shell output · exit 0
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "addition_timing_answer"
  },
  "user_facts": [
    "1 litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.",
    "Salt will be added; its amount and the pot, heater and room conditions are unspecified."
  ],
  "model_choices": [
    "Deterministic lumped calorimetry with constant water-plus-pot capacity C>0 and additive salt contribution S>=0; pot initially at 20 C.",
    "Compare fixed salt amount, salt initial temperature Ts, dissolution energy H, pressure and final boiling temperature B across schedules; all remain symbolic and unestimated.",
    "Instantaneous complete dissolution and mixing; no material loss, evaporation, phase change before endpoint, mixing delay or stove interruption. Only physically feasible pre-boiling addition schedules apply.",
    "Constant positive net powers P before salting and Q afterward, identical across compared schedules; equal powers is a conditional special case, not inferred from the data."
  ],
  "sources": [
    "https://openstax.org/books/university-physics-volume-2/pages/1-4-heat-transfer-specific-heat-and-calorimetry",
    "https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties"
  ],
  "incorporated_inputs": [],
  "proof_scope": "Derives total boiling time from preheating, mixing/dissolution and postheating energy balances. Proves the exact earlier/later/equal timing comparison according to the sign of Q-P, and the temperature-independent time for equal net powers. Does not estimate any physical parameters or establish model applicability, a unique real-world optimum, or human approval."
}
Answer and practical interpretation

The supplied information does not identify a best salt-addition temperature or heating time. Under a well-mixed, constant-net-power model with negligible evaporation and instantaneous dissolution, every admissible addition time gives the SAME time to the final salted solution's boiling point. Adding the salt now at 20 degrees C is therefore as fast as waiting in that model. This is a conditional tie, not evidence that immediate addition is the unique real-world optimum. There is no supported numerical waiting time.

Waiting until the unsalted water boils does not avoid heating the salt, supplying any endothermic dissolution energy, or reaching the solution's higher boiling temperature. The endpoint here is arrival of the mixed salted liquid at its equilibrium boiling temperature, not a momentary burst of bubbles. Do not extend this model to prolonged unsalted boiling: evaporation then changes both mass and concentration.

Supplied information

The user supplies 1 litre of water initially at 20 degrees C in a pot being heated by a stove. The salt quantity, pot, heater and room conditions are unspecified. No temperature-versus-time observations, power measurements, pressure, salt temperature, or dissolution observations are supplied. There is no dataset from which to estimate heating parameters. The volume does not specify the combined water-plus-pot heat capacity; it is retained as context rather than converted to an invented exact mass or capacity.

Additional modeling choices and their reasons

Use deterministic lumped calorimetry, not Bayesian inference: there are no noisy measurements requiring a likelihood or a prior. Interpret salt as a soluble nonvolatile cooking salt, completely dissolved at the endpoint. Hold its amount, starting temperature, pressure, and final composition fixed when comparing schedules. The final boiling temperature B is accordingly fixed across those comparisons but remains unknown; do not assume B = 100 degrees C. Boiling-point elevation motivates this distinction, but its numerical size is not needed or inferred.

Approximate water and pot by one uniform temperature and constant combined heat capacity C > 0. Approximate the added salt's sensible heat capacity contribution by S >= 0, so the salted system has capacity C+S. This additive, temperature-independent capacity is a simplifying choice, not an exact property of brine. Represent the fixed dissolution energy cost by H, positive for endothermic dissolution. Allow H to remain symbolic, including either sign; do not insert an unmeasured enthalpy. The salt starts at Ts. Heat exchanged during instantaneous mixing is internal; H is paid by the sensible thermal energy. No loss of material, latent heat expenditure, mixing delay, stirring work, spillage or stove interruption is included. Treat the pot as initially at the water temperature. Only schedules with no phase change before the endpoint fall within the model's physical applicability; in particular the pre-addition temperature must not exceed the pure-water boiling temperature at the actual pressure. The Lean inequalities alone do not encode that pressure-dependent restriction.

First allow constant positive net powers P before addition and Q afterward. Net means energy actually entering the modeled thermal system, after heat loss. Treating either as constant is a chosen approximation; the stove setting alone does not imply constant net power. This family exposes dependence on an unidentified parameter rather than inferring that salt necessarily changes heating power. Its equal-power special case P=Q is the simple negligible-loss, unchanged-heater baseline. Actual temperature-dependent heat losses, evaporation, variable heat capacities and dissolution kinetics require a richer model or measurements. The theorem does not choose an optimum for those systems.

Definitions, equations, and inference

The public definitions are initialTemperature = 20 degrees C, HeatingRun (x: pre-addition temperature, a: elapsed addition time, z: post-mixing temperature, t: elapsed boiling time) and HeatBalance. Times are in seconds, temperatures in degrees C, capacities in J/K, energies in J, powers in W. A common arbitrary sensible-enthalpy reference permits using C*x; only differences enter the balances.

HeatBalance says 20 <= x, 0 <= a <= t, z <= B, and:
  P*a = C*(x-20)                       [heating before addition]
  (C+S)*z = C*x + S*Ts - H             [mixing and dissolution]
  Q*(t-a) = (C+S)*(B-z)                [heating after addition]
These are physical assumptions, not supplied observations. For positive capacities and powers, linear heating between the endpoints is monotone, so the last equation corresponds to first arrival at B in this ideal model.

The intermediate lemma time_from_balance eliminates both a and z using these balances and proves:
  t(x) = C*(x-20)/P + ((C+S)*B-C*x-S*Ts+H)/Q.
Thus salt heating and dissolution have not been omitted or assumed to cancel independently of the model. For two runs at x<y it derives:
  P*Q*(t(y)-t(x)) = C*(y-x)*(Q-P).

The single final theorem addition_timing_answer proves all of the following, conditional on the stated balances and positive C,P,Q with S>=0:
  earlier addition finishes sooner iff Q>P;
  later addition finishes sooner iff Q<P;
  completion times are equal iff Q=P;
  when Q=P, t = ((C+S)*B-C*20-S*Ts+H)/P.
For the unequal-power model, these pairwise comparisons imply preference for the earliest or latest feasible addition, respectively; no feasible upper addition temperature or time is numerically specified here. In the equal-power case all feasible addition temperatures tie. Addition time and pre-addition temperature correspond through a=C*(x-20)/P, with P itself unidentified. Nothing supplied fixes the sign of Q-P or the common time, so this analysis cannot support a universal real-world optimum or a number of seconds. These are conditional predictions, not parameter estimates or performed experiments.

Compact review boundary

Supplied: 1 litre initially at 20 degrees C; heating on a stove; unspecified salt and apparatus.
Independent choices: fixed final composition/pressure; lumped constant additive capacities; fixed salt initial temperature and dissolution cost; instantaneous complete mixing/dissolution; no evaporation or other phase changes before endpoint; positive stagewise constant net powers and unchanged parameters across schedules. Equal net powers is an additional special-case assumption, not a consequence of the user facts.
Necessary definitions: initialTemperature, HeatingRun and HeatBalance, exactly as translated above.
Proved: energy-balance elimination, temperature-dependent time difference, and the comparison/equal-power answer. No added axioms or sorry are intended. The theorem does not prove that the chosen physical approximations hold in the user's kitchen, that either power relation actually occurs there, or that the data estimate any of these parameters. No human approval is claimed.

Sources and limitations

OpenStax, University Physics Volume 2, section 1.4, Heat Transfer, Specific Heat, and Calorimetry:
https://openstax.org/books/university-physics-volume-2/pages/1-4-heat-transfer-specific-heat-and-calorimetry
Consulted for general calorimetry and conservation-of-energy background. It motivates the lumped sensible-heat balance, not this pot's parameter values or the constancy of its net power.

OpenStax, Chemistry 2e, section 11.4, Colligative Properties:
https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties
Consulted for the vapor-pressure definition of boiling and solute-induced boiling-point elevation. No numerical dilute-solution formula or concentration is assumed in the proof.

These are general educational sources, not measurements of this system. Web consultation on 2026-11-16. No operator responses have been requested or incorporated. The formal check establishes only the mathematical implication from the explicit assumptions; physical applicability and the adequacy of the scientific answer remain for human review.

Check history (raw traces retained under checks/ and diagnostics/): the first attempt failed because the umbrella Mathlib.Tactic module was unavailable; specific tactic imports fixed that. The second attempt compiled and passed kernel rechecking but failed exact extraction identity because a numeral instance proof was shared differently. Naming the supplied initial temperature explicitly addresses this representation issue without changing any physical assumptions or mathematical conclusions. The final check result is reported separately by the harness.
{
  "decision": "reject",
  "binding": "3a20a8475cfe729b5af2571186d7955b130ea30b973191670a2a8c415ca373d9",
  "reason": "Human TUI feedback: propose and prove how net heating power changes after adding salt. Derive the relationship from an explicit physical model and exposed assumptions, rather than leaving before/after net powers unrelated, and use it to answer the salt-addition timing question. Request experiments if needed. This is a request to revise; no acceptance of the current result.",
  "time": "2026-11-17T14:13:17.588492+00:00",
  "verification_verdict": "proved"
}
shell input
{
  "command": "/usr/bin/bash -lc 'find checks diagnostics -type f'"
}
shell output · exit 0
checks/cd3bf32329e547d19d474c1bd79431b9/submitted-report.txt
checks/cd3bf32329e547d19d474c1bd79431b9/submitted-candidate.json
checks/cd3bf32329e547d19d474c1bd79431b9/lean.log
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
checks/cd3bf32329e547d19d474c1bd79431b9/extracted.json
checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean
checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-report.txt
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-candidate.json
checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-report.txt
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-candidate.json
checks/f49ea96bd5de45babf8f3c699ba15e09/lean.log
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.json
checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean
checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean
diagnostics/extraction-result.txt
diagnostics/extract-trace-1.txt
diagnostics/extraction_trace.py
diagnostics/extract-trace-2.txt
diagnostics/extracted.json
diagnostics/extracted.lean
shell input
{
  "command": "/usr/bin/bash -lc \"cat checks/*/verdict.json; which lean; ls /harness; printenv | rg 'LEAN|LAKE'\""
}
shell output · exit 127 · failed
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-16T18:27:31.048579+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "HeatingRun",
      "HeatBalance"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "52894b2acf5bc09ce197451177b4618f9dbe95c87b766f295812a03077606c18",
        "extracted_sha256": "52894b2acf5bc09ce197451177b4618f9dbe95c87b766f295812a03077606c18"
      }
    },
    "dependency_faithful": {
      "HeatingRun": true,
      "HeatingRun.mk": true,
      "HeatBalance": true,
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "HeatingRun.x": true,
      "HeatingRun.a": true,
      "HeatingRun.t": true,
      "HeatingRun.z": true
    },
    "dependency_identities": {
      "HeatingRun": {
        "original_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e",
        "extracted_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e"
      },
      "HeatingRun.mk": {
        "original_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429",
        "extracted_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429"
      },
      "HeatBalance": {
        "original_sha256": "2e5a83c6c8dda7b7be5db30875038773a065f300c0e75be490f5e69df9d81069",
        "extracted_sha256": "2e5a83c6c8dda7b7be5db30875038773a065f300c0e75be490f5e69df9d81069"
      },
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "HeatingRun.x": {
        "original_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4",
        "extracted_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4"
      },
      "HeatingRun.a": {
        "original_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8",
        "extracted_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8"
      },
      "HeatingRun.t": {
        "original_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4",
        "extracted_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4"
      },
      "HeatingRun.z": {
        "original_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423",
        "extracted_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B P Q : \u211d) (r s : HeatingRun), 0 < C \u2192 0 \u2264 S \u2192 0 < P \u2192 0 < Q \u2192 HeatBalance C S H Ts B P Q r \u2192 HeatBalance C S H Ts B P Q s \u2192 r.x < s.x \u2192 (r.t < s.t \u2194 P < Q) \u2227 (s.t < r.t \u2194 Q < P) \u2227 (s.t = r.t \u2194 Q = P) \u2227 (Q = P \u2192 r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P)"
    },
    "extracted_file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:25:46.169042+00:00",
  "lean_exit": 1,
  "error": "Lean, kernel recheck or axiom audit failed; see lean.log"
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:26:03.961421+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
entrypoint.sh
lean-toolchain
src
/usr/bin/bash: line 1: rg: command not found
web_search input
{
  "query": "site.openstax.org Newton law cooling heat transfer rate temperature difference ...",
  "action": {
    "type": "search",
    "queries": [
      "site.openstax.org Newton law cooling heat transfer rate temperature difference",
      "site.openstax.org chemistry sodium chloride dissolution endothermic enthalpy"
    ]
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "pmt.physicsandmathstutor.com",
      "ref_id": "turn0search12",
      "snippet": "*explain how enthalpy changes of solution are related to lattice breaking enthalpies and hydration enthalpies of the ions;* ... For an ionic solid to dissolve",
      "title": "GCE AS/A CHEMISTRY 34",
      "url": "https://pmt.physicsandmathstutor.com/download/Chemistry/A-level/Notes/WJEC-Old/Unit-5/Notes%20-%20Unit%205%20WJEC%20Chemistry%20A-level.pdf"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn0search0",
      "snippet": "As illustrated in Figure 11.4, the formation of a solution may be viewed as a stepwise process in which energy is consumed to overcome solute-solute",
      "title": "11.1 The Dissolution Process - Chemistry 2e | OpenStax",
      "url": "https://openstax.org/books/chemistry-2e/pages/11-1-the-dissolution-process"
    },
    {
      "type": "text_result",
      "domain": "inklearning.co.uk",
      "ref_id": "turn0search1",
      "snippet": "The lattice enthalpy of dissociation of sodium chloride is +787 kJ mol⁻¹. ... Hydrated calcium chloride, CaCl₂·6H₂O, dissolves endothermically: its ions are already surrounded by",
      "title": "Enthalpies of solution and hydration | A-level Chemistry",
      "url": "https://inklearning.co.uk/chemistry/thermodynamics/enthalpies-of-solution-and-hydration/"
    },
    {
      "type": "text_result",
      "domain": "bpb-us-e1.wpmucdn.com",
      "ref_id": "turn0search13",
      "snippet": "Modes of heat transfer ... where T∞is the temperature of the oncoming fluid. ... This result is usually called Newton’s law of cooling, although Newton",
      "title": "A Heat Transfer Textbook",
      "url": "https://bpb-us-e1.wpmucdn.com/sites.mit.edu/dist/6/1810/files/2020/08/AHTTv510.pdf"
    },
    {
      "type": "text_result",
      "domain": "sathee.iitk.ac.in",
      "ref_id": "turn0search2",
      "snippet": "According to Newton’s law of cooling, the rate of loss of heat, $-\\mathrm{d} Q / \\mathrm{d} t$ of the body is directly proportional to the",
      "title": "Chapter 10 Thermal Properties of Matter | SATHEE JEE",
      "url": "https://sathee.iitk.ac.in/as/sathee-jee/ncert-books/jee-ncert-books/jee-nb-phy-11/phy-11-chapter-10-thermal-properties-of-matter/"
    },
    {
      "type": "text_result",
      "domain": "ncert.waala.in",
      "ref_id": "turn0search14",
      "snippet": "According to Newton’s law of cooling, the rate of loss of heat, \\(-dQ/dt\\) of the body is directly proportional to the difference of temperature \\(\\Delta",
      "title": "E:\\Textbook\\12 Rationalised Textbook\\11087 — Physics Part II\\1 Source Files\\11087 — Physics Part II\\3 Chapter-10\\Chapter 10.pmd",
      "url": "https://ncert.waala.in/uploads/ncert-class-11/physics-part-2/chapter-10-thermal-properties-of-matter-1765385220.pdf"
    },
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn0search15",
      "snippet": "The integral heat of solution at infinite dilution ΔH_s° is the enthalpy change for dissolution of 1 mole of crystalline sodium chloride in an infinite",
      "title": "ØCJ",
      "url": "https://srd.nist.gov/JPCRD/jpcrd272.pdf"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn0search3",
      "snippet": "One of the major effects of heat transfer is temperature change: Heating increases the temperature while cooling decreases it.",
      "title": "11.2 Heat, Specific Heat, and Heat Transfer - Physics | OpenStax",
      "url": "https://openstax.org/books/physics/pages/11-2-heat-specific-heat-and-heat-transfer"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search4",
      "snippet": "Enthalpies of solution may be either positive or negative - in other words, some ionic substances dissolved endothermically (for example, NaCl); others dissolve exothermically (for",
      "title": "5.9: Enthalpy of Solution - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/Northern_Michigan_University/CH_215%3A_Chemistry_of_the_Elements_Fall_2023/05%3A_Solids_and_Solid-State_Chemistry/5.09%3A_Enthalpy_of_Solution"
    },
    {
      "type": "text_result",
      "domain": "static1.squarespace.com",
      "ref_id": "turn0search16",
      "snippet": "| sodium chloride | +3.87 | Endothermic | ... Change in enthalpy ΔH° in kJ/mol in water at 25°C[1] ... ## Visual examples of exothermic",
      "title": "AP Chem 015 - Solutions PDF",
      "url": "https://static1.squarespace.com/static/50d5cc57e4b0e383f5b1eb34/t/52c06cd6e4b09c178bb18a1e/1388342486282/AP%2BChem-015%2BSolutions%2BKN%2BPDF.pdf"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search5",
      "snippet": "Figure \\(\\PageIndex{1}\\): Hydration shells around some ions in a sodium chloride solution. ... The enthalpy difference of the first step is the lattice energy and",
      "title": "8.2.2D: Solutions of Solid Solutes in Liquid Solvents - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/General_Chemistry/Chem1_%28Lower%29/08%253A_Solutions/8.02%253A_Thermodynamics_of_Solutions/8.2.2D%253A_8.2.2D%253A_Solutions_of_Solid_Solutes_in_Liquid_Solvents"
    },
    {
      "type": "text_result",
      "domain": "fenix.tecnico.ulisboa.pt",
      "ref_id": "turn0search17",
      "snippet": "Newton’s law of cooling states that the temperature of a cooling body falls exponentially towards the temperature of its surroundings with a rate proportional to",
      "title": "Concepts in Thermal Physics",
      "url": "https://fenix.tecnico.ulisboa.pt/downloadFile/2252418288980305/%5BBlundell_2010_Oxford%5D_Concepts_in_Thermal_Physics_2ndEd.pdf"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn0search6",
      "snippet": "where P is the power or rate of heat transfer in watts or in kilocalories per second, A and d are its surface area and",
      "title": "1.6 Mechanisms of Heat Transfer - University Physics Volume 2 | OpenStax",
      "url": "https://openstax.org/books/university-physics-volume-2/pages/1-6-mechanisms-of-heat-transfer"
    },
    {
      "type": "text_result",
      "domain": "pmc.ncbi.nlm.nih.gov",
      "ref_id": "turn0search7",
      "snippet": "Open in a new tab ... In order to describe exactly the dissolution act or process, two methods were used, namely, the total heat of",
      "title": "Explanation and Exploration of the Isothermal Titration Curve for the NaCl + Na2SO4 + H2O System at 298.15 K and 102.2 kPa",
      "url": "https://pmc.ncbi.nlm.nih.gov/articles/PMC9330105/"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search8",
      "snippet": "In the discussion of lattice energy, we consider the ions separated into a gas form whereas in the dissolution process, the ions are also separated,",
      "title": "Hydration - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_%28Physical_and_Theoretical_Chemistry%29/Thermodynamics/Energies_and_Potentials/Enthalpy/Hydration"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search9",
      "snippet": "Energy is required to overcome the intermolecular interactions in a solute, which can be supplied only by the new interactions that occur in the solution,",
      "title": "11.2: The Dissolution Process - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Workbench/OpenStax_Chemistry_Remixed%3A_Clovis_Community_College/11%3A_Solutions_and_Colloids/11.02%3A_The_Dissolution_Process"
    },
    {
      "type": "text_result",
      "domain": "www.space.com",
      "ref_id": "turn0news40",
      "snippet": "Temperature is a measurement of the speed at which particles are moving, and heat is how much energy the particles of an object have. ...",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/qD9x1waavKXH0towEQrB8Y3h5i722iBEa5an3OmuGMrIRMtoLXEXNB9ZVh9kzuGJRNpdRgjTzRdKXwgwZxfeMmyCCESk3Fj5ZpIOsdRtfpgsxLqJMH2MymEFvaOduV3Q",
      "title": "How cold is space? Physics behind the temperature of the universe",
      "url": "https://www.space.com/how-cold-is-space"
    },
    {
      "type": "text_result",
      "domain": "www.tomshardware.com",
      "ref_id": "turn0news41",
      "snippet": "In laboratory tests, Joule heating the actuator to 86°C produced a 12.9 K temperature span across the refrigerant film - the difference between its hottest",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/hvLbyob8NBnqBgzoFQf7YT_f-yRiZn3BZ04YBI7uM0f8kH1CgArsLuKvYPUdNctSThBKbKJ29692_JOR9lM1nT0ySt7EuOiGC85hKcxIFYWj0MQzCGk-EFIRxINzAMnd",
      "title": "Motorless solid-state cooler uses heat to cool itself; could recycle processor heat into cooling - shape-memory alloy films could turn data center exhaust into refrigeration",
      "url": "https://www.tomshardware.com/tech-industry/manufacturing/motorless-solid-state-cooler-uses-heat-to-cool-itself-could-recycle-processor-heat-into-cooling-shape-memory-alloy-films-could-turn-data-center-exhaust-into-refrigeration"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /opt; ls -la /harness/src; cat checks/cd3bf32329e547d19d474c1bd79431b9/lean.log; find / -maxdepth 4 -name lakefile.toml -o -name lean -o -name Mathlib 2>/dev/null'"
}
shell output · exit 1 · failed
total 12
drwxr-xr-x 1 root root 4096 Nov 17 14:13 .
drwxr-xr-x 1 root root 4096 Nov 17 14:13 ..
drwxr-xr-x 7 1001 1001 4096 Oct 15 19:13 lean
total 84
drwxr-xr-x 2 root root  4096 Nov 17 14:13 .
drwxr-xr-x 4 root root  4096 Nov 17 14:13 ..
-rw-rw-r-- 1 1001 1001 13714 Nov 16 18:09 vcs_extract.py
-rw-rw-r-- 1 1001 1001  7329 Nov 16 18:09 vcs_lean.py
-rw-rw-r-- 1 1001 1001 50402 Nov 16 18:16 vcs_protocol.py
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean:68:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean:103:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean:68:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean:103:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
'addition_timing_answer' depends on axioms: [propext, Classical.choice, Quot.sound]
VAS_LISTED

leanchecker exit 0

/opt/lean
/opt/lean/include/lean
/opt/lean/bin/lean
/opt/lean/share/lean
/opt/lean/src/lean
/opt/lean/lib/lean
web_search input
{
  "query": "https://openstax.org/books/university-physics-volume-2/pages/1-6-mechanisms-of-heat-transfer",
  "action": {
    "type": "open_page",
    "url": "https://openstax.org/books/university-physics-volume-2/pages/1-6-mechanisms-of-heat-transfer"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn1view0",
      "snippet": "Total lines: 362",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/JN2vxI697TSmsaI2i_D4UJSoW3Jm8faCjKNHRWtXQZd_Q8G_yzF9XKlT4zVbOgOrKDwK4_AcBQheHRNumWYyKj-Cgtljf278pewQLTLcih8G3UU-pXcXQQOjA0BATtjE",
      "title": "1.6 Mechanisms of Heat Transfer - University Physics Volume 2 | OpenStax",
      "url": "https://openstax.org/books/university-physics-volume-2/pages/1-6-mechanisms-of-heat-transfer"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn1view1",
      "snippet": "Total lines: 154",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/yxWhf_E7vQ5yFLEvQDGLPGE-_0FSmmRZUlyC_1SMyRawjB_0YBE-PEJtp4HCoqmTm2FntirSWBIdVDaSrutGgRF7p1e4jKzivDXG5nhdd3ZicUgEeoJx0QeldwZA90Oolg7o_HAhcvMFI0YyLaRW1A",
      "title": "11.1 The Dissolution Process - Chemistry 2e | OpenStax",
      "url": "https://openstax.org/books/chemistry-2e/pages/11-1-the-dissolution-process"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc \"ls -la /opt/lean; sed -n '1,170p' /harness/src/vcs_lean.py; find /opt/lean -maxdepth 5 -type d -name Mathlib\""
}
shell output · exit 0
total 124
drwxr-xr-x 7 1001 1001  4096 Oct 15 19:13 .
drwxr-xr-x 1 root root  4096 Nov 17 14:13 ..
-rw-r--r-- 1 1001 1001  9160 Oct 12 16:23 LICENSE
-rw-r--r-- 1 1001 1001 81940 Oct 12 16:23 LICENSES
drwxr-xr-x 2 1001 1001  4096 Oct 15 19:13 bin
drwxr-xr-x 4 1001 1001  4096 Oct 15 19:13 include
drwxr-xr-x 5 1001 1001  4096 Oct 15 19:13 lib
drwxr-xr-x 3 1001 1001  4096 Oct 15 19:13 share
drwxr-xr-x 3 1001 1001  4096 Oct 15 19:13 src
"""Restricted Lean validation and kernel-environment assumption audit.

Stable VAS_ audit markers preserve compatibility with recorded evidence.
"""
import os
from pathlib import Path
import re

ROOT = Path(__file__).resolve().parents[1]
_TOOLCHAIN = (ROOT / "lean-toolchain").read_text().strip().replace("/", "--").replace(":", "---")
LEAN = os.environ.get("VAS_LEAN") or str(Path(os.environ.get("ELAN_HOME", Path.home() / ".elan")) / "toolchains" / _TOOLCHAIN / "bin/lean")
LEANCHECKER = str(Path(LEAN).with_name("leanchecker"))
ALLOWED_AXIOMS = {"propext", "Classical.choice", "Quot.sound"}
FORBIDDEN = re.compile(
    r"\b(axioms|native_decide|implemented_by|extern|unsafe|opaque|import|"
    r"macro|macro_rules|syntax|elab|notation|infix|infixl|infixr|prefix|postfix|"
    r"run_cmd|run_tac|run_elab|run_meta|initialize|builtin_initialize|instance|attribute|"
    r"partial|private|local|scoped|namespace|section|end|universe|variable|export|IO|System|"
    r"Lean|native|simproc|dsimproc)\b"
    # any word containing elab (by_elab, elab_rules, run_elab: `\belab\b` misses them, `_` is a word character);
    # backtick name literals and quotations are metaprogramming, which a proof body never needs (OT-1861)
    r"|\w*elab\w*|`|#|@\[|\$|«|»")


def strip_comments(source):
    out, i, depth = [], 0, 0
    while i < len(source):
        if source.startswith("/-", i):
            depth += 1
            i += 2
        elif depth and source.startswith("-/", i):
            depth -= 1
            i += 2
        elif depth:
            i += 1
        elif source.startswith("--", i):
            j = source.find("\n", i)
            i = len(source) if j == -1 else j
            out.append("\n")
        else:
            out.append(source[i])
            i += 1
    if depth:
        raise ValueError("Unclosed Lean comment")
    return "".join(out)


def validate(source, required):
    if not isinstance(source, str) or not 0 < len(source.encode()) <= 24000:
        raise ValueError("Lean body must contain at most 24000 UTF-8 bytes")
    code = strip_comments(source)
    if '"' in code:
        raise ValueError("Put prose in comments; executable strings are outside this contract")
    code = re.sub(r"^\s*set_option (maxRecDepth|maxHeartbeats) \d+\s*$", "", code, flags=re.M)
    if re.search(r"\bset_option\b", code):
        raise ValueError("Only maxRecDepth/maxHeartbeats options are available")
    if "VAS_" in code:
        raise ValueError("Names containing VAS_ are reserved for the checker's own report")
    bad = FORBIDDEN.search(code)
    if bad:
        raise ValueError(f"Outside the restricted Lean contract: {bad.group()}")
    if re.search(r"\b(?:def|abbrev|theorem|lemma|structure|inductive|class)\s+[^\s:(]+\.", code):
        raise ValueError("Declare plain top-level names; namespaces are outside this contract")
    theorems = re.findall(r"^\s*(?:theorem|lemma)\s+([A-Za-z_][A-Za-z_0-9']*)", code, re.M)
    missing = [n for n in required if n not in theorems]
    if missing:
        raise ValueError(f"Missing required theorems: {missing}")
    if re.search(r"\baxiom\b(?!\s+[A-Za-z_][A-Za-z_0-9']*\s*[:({\[])", code):
        raise ValueError("Declare an added assumption as `axiom name : statement` at the start of a line")
    return theorems


# Lean itself lists what the proof adds: every axiom declared in the file and every sorry (by its elaborated goal with
# the hypotheses in scope), each marked used when a conclusion theorem reaches it. Read from the checked kernel
# environment, as #print axioms does. Never part of an agent body (run_cmd is outside the contract).
LISTER = """
/-- true if `sorryAx` occurs anywhere other than as the head of an application that states its goal -/
private partial def VAS_unstated : Lean.Expr → Bool
  | e@(.app ..) =>
    let f := e.getAppFn
    (if f.isConstOf ``sorryAx then false else VAS_unstated f) || e.getAppArgs.any VAS_unstated
  | .const n _ => n == ``sorryAx
  | .lam _ t b _ | .forallE _ t b _ => VAS_unstated t || VAS_unstated b
  | .letE _ t v b _ => VAS_unstated t || VAS_unstated v || VAS_unstated b
  | .mdata _ b | .proj _ _ b => VAS_unstated b
  | _ => false

set_option format.width 100000 in
set_option pp.deepTerms true in
set_option pp.proofs true in
set_option pp.maxSteps 100000000 in
open Lean Elab Command Meta in
run_cmd do
  let kenv := (← getEnv).checked.get
  let locals := kenv.constants.map₂.toList
  let localSet : NameSet := locals.foldl (fun s (n, _) => s.insert n) {}
  let exprsOf (ci : ConstantInfo) : Array Expr :=
    #[ci.type] ++ (match ci with
      | .defnInfo v => #[v.value] | .thmInfo v => #[v.value] | .opaqueInfo v => #[v.value] | _ => #[])
  let mut used : NameSet := {}
  let mut todo : List Name := ROOTS
  while !todo.isEmpty do
    let n := todo.head!
    todo := todo.tail!
    if used.contains n then continue
    used := used.insert n
    if let some ci := kenv.find? n then
      for e in exprsOf ci do
        for c in e.getUsedConstants do
          if localSet.contains c && !used.contains c then todo := c :: todo
  for (n, ci) in locals do
    if let .axiomInfo _ := ci then
      logInfo m!"VAS_AXIOM {n} used={used.contains n} : {← liftTermElabM <| ppExpr ci.type} VAS_END"
    -- every declaration kind, type and value: a gap may sit in an axiom's type as well as in a proof
    for e in exprsOf ci do
      -- hasSorry is cached and linear; VAS_unstated walks the term as a tree, exponential on shared proofs
      if e.hasSorry && VAS_unstated e then
        logInfo m!"VAS_GAP {n} used={used.contains n} : (sorry with no stated goal: it can assert anything) VAS_END"
        logInfo m!"VAS_UNSTATED {n} used={used.contains n}"
    if (exprsOf ci).any (·.hasSorry) then
      let seen ← IO.mkRef ({} : Std.HashSet String)
      liftTermElabM do
        for e in exprsOf ci do
          forEachExpr' e fun sub => do
            if sub.isAppOf ``sorryAx && sub.getAppNumArgs ≥ 1 then
              let mut t ← instantiateMVars (sub.getArg! 0)
              if t.isForall && t.bindingDomain!.isConstOf ``Lean.Name then t := t.bindingBody!
              let hyps ← (← getLCtx).foldlM (init := m!"") fun acc d => do
                if d.isImplementationDetail then return acc
                match d.value? with
                | some v => return acc ++ m!"({d.userName} : {← ppExpr d.type} := {← ppExpr v}) "
                | none => return acc ++ m!"({d.userName} : {← ppExpr d.type}) "
              let line ← (m!"VAS_GAP {n} used={used.contains n} : {hyps}⊢ {← ppExpr t} VAS_END").toString
              unless (← seen.get).contains line do
                seen.modify (·.insert line)
                logInfo line
            return true
  logInfo "VAS_LISTED"
"""


def listed(text):
    """Parse the lister's output into added_assumptions entries; None if the lister did not finish."""
    if not re.search(r"^VAS_LISTED\s*$", text, re.M):  # the marker line itself, not a substring of other output
        return None
    out = []
    for kind, name, used, stmt in re.findall(r"VAS_(AXIOM|GAP) (\S+) used=(true|false) : (.*?) VAS_END", text, re.S):
        out.append({"kind": kind.lower(), "in" if kind == "GAP" else "name": name, "used": used == "true",
                    "statement": " ".join(stmt.split())})
    return out
shell input
{
  "command": "/usr/bin/bash -lc 'find / -maxdepth 5 -type d -name Mathlib 2>/dev/null; ls -la /work/../; cat /harness/entrypoint.sh'"
}
shell output · exit 0
total 76
drwxr-xr-x   1 root root 4096 Nov 17 14:13 .
drwxr-xr-x   1 root root 4096 Nov 17 14:13 ..
-rwxr-xr-x   1 root root    0 Nov 17 14:13 .dockerenv
lrwxrwxrwx   1 root root    7 Jul 17 17:05 bin -> usr/bin
drwxr-xr-x   2 root root 4096 Jul 17 17:05 boot
drwxr-xr-x   3 root root 4096 Nov 17 14:13 deps
drwxr-xr-x   5 root root  340 Nov 17 14:13 dev
drwxr-xr-x   1 root root 4096 Nov 17 14:13 etc
drwxr-xr-x   4 root root 4096 Nov 17 14:13 harness
drwxr-xr-x   1 root root 4096 Nov 17 14:13 home
lrwxrwxrwx   1 root root    7 Jul 17 17:05 lib -> usr/lib
lrwxrwxrwx   1 root root    9 Jul 17 17:05 lib64 -> usr/lib64
drwxr-xr-x   2 root root 4096 Nov  4 21:23 media
drwxr-xr-x   2 root root 4096 Nov  4 21:23 mnt
drwxr-xr-x   2 root root 4096 Nov 17 14:13 native-auth
drwxr-xr-x   1 root root 4096 Nov 17 14:13 opt
dr-xr-xr-x 524 root root    0 Nov 17 14:13 proc
drwxr-xr-x   2 root root 4096 Nov 17 14:13 protocol
drwx------   1 root root 4096 Nov  5 07:57 root
drwxr-xr-x   3 root root 4096 Nov  4 21:23 run
lrwxrwxrwx   1 root root    8 Jul 17 17:05 sbin -> usr/sbin
drwxr-xr-x   2 root root 4096 Nov  4 21:23 srv
dr-xr-xr-x  13 root root    0 Nov 17 14:13 sys
drwxrwxrwt   2 root root   40 Nov 17 14:13 tmp
drwxr-xr-x   1 root root 4096 Nov  4 21:23 usr
drwxr-xr-x   1 root root 4096 Nov  4 21:23 var
drwxrwxr-x   4 1001 1001 4096 Nov 17 14:13 work
#!/bin/sh
set -eu
# HOME is fresh tmpfs; Docker creates bind-mount parents as root. Mount only the
# native credential file and symlink it into an independently writable HOME.
if [ -f /native-auth/auth.json ]; then
    mkdir -p "$HOME/.codex"
    ln -s /native-auth/auth.json "$HOME/.codex/auth.json"
fi
if [ -f /native-auth/claude-credentials.json ]; then
    mkdir -p "$CLAUDE_CONFIG_DIR"
    ln -s /native-auth/claude-credentials.json "$CLAUDE_CONFIG_DIR/.credentials.json"
    # Fresh non-account preferences only. Never copy host ~/.claude.json.
    printf '%s\n' '{"hasCompletedOnboarding":true,"bypassPermissionsModeAccepted":true}' > "$CLAUDE_CONFIG_DIR/.claude.json"
fi
exec "$@"
assistant
The previous proof left the heating powers before and after salting unrelated; that is the gap identified by the human review. I’m replacing them with a shared heater and a temperature-dependent heat-loss law. Under this model, cool salt and endothermic dissolution lower the liquid temperature, reducing heat loss. I’ll check whether that makes immediate addition faster overall, including the extra energy needed to heat and dissolve the salt.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /deps; find /deps -maxdepth 5 -type d | head -60; ls /opt/lean/bin'"
}
shell output · exit 0
total 12
drwxr-xr-x 3 root root 4096 Nov 17 14:13 .
drwxr-xr-x 1 root root 4096 Nov 17 14:13 ..
drwxrwxr-x 3 1001 1001 4096 Nov 16 18:13 click
/deps
/deps/click
/deps/click/__pycache__
cadical
clang
con-leche
con-ron
lake
ld.lld
lean
lean4lean
leanc
leanchecker
leanchecker-paranoid
leanexport
leanir
leanmake
leantar
llvm-ar
nanoda_bin
shell input
{
  "command": "/usr/bin/bash -lc \"ls -la /home/[user] ls -la /opt/lean/lib/lean; /opt/lean/bin/lean --print-prefix; find / -maxdepth 4 -type l -name '*math*' 2>/dev/null; sed -n '175,290p' /harness/src/vcs_lean.py\""
}
shell output · exit 0
total 4
drwxrwxrwt 3 root root   60 Nov 17 14:13 .
drwxr-xr-x 1 root root 4096 Nov 17 14:13 ..
drwxr-xr-x 9 1001 1001  620 Nov 17 14:13 .codex
total 629480
drwxr-xr-x  7 1001 1001      4096 Oct 15 19:13 .
drwxr-xr-x  5 1001 1001      4096 Oct 15 19:13 ..
drwxr-xr-x 11 1001 1001     12288 Oct 15 19:13 Init
-rw-r--r--  1 1001 1001      1643 Oct 12 16:34 Init.ilean
-rw-r--r--  1 1001 1001      5784 Oct 12 16:34 Init.ir
-rw-r--r--  1 1001 1001       176 Oct 12 16:34 Init.ir.sig
-rw-r--r--  1 1001 1001      5632 Oct 12 16:34 Init.olean
-rw-r--r--  1 1001 1001        96 Oct 12 16:34 Init.olean.private
-rw-r--r--  1 1001 1001        96 Oct 12 16:34 Init.olean.server
drwxr-xr-x 10 1001 1001      4096 Oct 15 19:13 Lake
-rw-r--r--  1 1001 1001       310 Oct 12 16:38 Lake.ilean
-rw-r--r--  1 1001 1001      1920 Oct 12 16:38 Lake.ir
-rw-r--r--  1 1001 1001       176 Oct 12 16:38 Lake.ir.sig
-rw-r--r--  1 1001 1001      1768 Oct 12 16:38 Lake.olean
-rw-r--r--  1 1001 1001        96 Oct 12 16:38 Lake.olean.private
-rw-r--r--  1 1001 1001        96 Oct 12 16:38 Lake.olean.server
-rw-r--r--  1 1001 1001       815 Oct 12 16:41 LakeMain.ilean
-rw-r--r--  1 1001 1001      2960 Oct 12 16:41 LakeMain.ir
-rw-r--r--  1 1001 1001       176 Oct 12 16:41 LakeMain.ir.sig
-rw-r--r--  1 1001 1001     12584 Oct 12 16:41 LakeMain.olean
-rw-r--r--  1 1001 1001      3968 Oct 12 16:41 LakeMain.olean.private
-rw-r--r--  1 1001 1001       608 Oct 12 16:41 LakeMain.olean.server
drwxr-xr-x 17 1001 1001     20480 Oct 15 19:13 Lean
-rw-r--r--  1 1001 1001      1786 Oct 12 16:40 Lean.ilean
-rw-r--r--  1 1001 1001      6112 Oct 12 16:40 Lean.ir
-rw-r--r--  1 1001 1001       176 Oct 12 16:40 Lean.ir.sig
-rw-r--r--  1 1001 1001      5960 Oct 12 16:40 Lean.olean
-rw-r--r--  1 1001 1001        96 Oct 12 16:40 Lean.olean.private
-rw-r--r--  1 1001 1001        96 Oct 12 16:40 Lean.olean.server
-rw-r--r--  1 1001 1001     12213 Oct 12 16:35 LeanChecker.ilean
-rw-r--r--  1 1001 1001    535632 Oct 12 16:35 LeanChecker.olean
drwxr-xr-x  2 1001 1001      4096 Oct 15 19:13 LeanExport
-rw-r--r--  1 1001 1001      2599 Oct 12 16:41 LeanExport.ilean
-rw-r--r--  1 1001 1001    109872 Oct 12 16:41 LeanExport.olean
-rw-r--r--  1 1001 1001     21294 Oct 12 16:38 LeanIR.ilean
-rw-r--r--  1 1001 1001    406024 Oct 12 16:38 LeanIR.ir
-rw-r--r--  1 1001 1001       176 Oct 12 16:38 LeanIR.ir.sig
-rw-r--r--  1 1001 1001      9136 Oct 12 16:38 LeanIR.olean
-rw-r--r--  1 1001 1001   1089288 Oct 12 16:38 LeanIR.olean.private
-rw-r--r--  1 1001 1001      2304 Oct 12 16:38 LeanIR.olean.server
-rw-r--r--  1 1001 1001      4662 Oct 12 16:34 Leanc.ilean
-rw-r--r--  1 1001 1001    258976 Oct 12 16:34 Leanc.olean
drwxr-xr-x 13 1001 1001      4096 Oct 15 19:13 Std
-rw-r--r--  1 1001 1001       352 Oct 12 16:36 Std.ilean
-rw-r--r--  1 1001 1001      2064 Oct 12 16:36 Std.ir
-rw-r--r--  1 1001 1001       176 Oct 12 16:36 Std.ir.sig
-rw-r--r--  1 1001 1001      1912 Oct 12 16:36 Std.olean
-rw-r--r--  1 1001 1001        96 Oct 12 16:36 Std.olean.private
-rw-r--r--  1 1001 1001        96 Oct 12 16:36 Std.olean.server
-rw-r--r--  1 1001 1001  26197506 Oct 12 16:34 libInit.a
-rw-r--r--  1 1001 1001      6264 Oct 12 16:41 libInit_shared.so
-rw-r--r--  1 1001 1001  22476306 Oct 12 16:41 libLake.a
-rw-r--r--  1 1001 1001  14070032 Oct 12 16:41 libLake_shared.so
-rw-r--r--  1 1001 1001 312347648 Oct 12 16:41 libLean.a
-rw-r--r--  1 1001 1001     69950 Oct 12 16:35 libLeanChecker.a
-rw-r--r--  1 1001 1001   1038398 Oct 12 16:41 libLeanExport.a
-rw-r--r--  1 1001 1001    279530 Oct 12 16:38 libLeanIR.a
-rw-r--r--  1 1001 1001     40268 Oct 12 16:35 libLeanc.a
-rw-r--r--  1 1001 1001  30173828 Oct 12 16:37 libStd.a
-rw-r--r--  1 1001 1001     14734 Oct 12 16:41 libinitialize_minimal.a
-rw-r--r--  1 1001 1001   2373186 Oct 12 16:31 libleancpp.a
-rw-r--r--  1 1001 1001       872 Oct 12 16:31 libleanmanifest.a
-rw-r--r--  1 1001 1001   1258058 Oct 12 16:32 libleanrt.a
-rw-r--r--  1 1001 1001 231113560 Oct 12 16:41 libleanshared.so
-rw-r--r--  1 1001 1001      6264 Oct 12 16:41 libleanshared_1.so
-rw-r--r--  1 1001 1001      6264 Oct 12 16:41 libleanshared_2.so
-rw-r--r--  1 1001 1001    382740 Oct 12 16:41 libmimalloc_paranoid.a
/opt/lean
shell input
{
  "command": "/usr/bin/bash -lc \"grep -nE 'mathlib|LEAN|subprocess|subscription|client|compile|lake' /harness/src/vcs_protocol.py\""
}
shell output · exit 0
16:import subprocess
30:NAME = re.compile(r"[A-Za-z_][A-Za-z_0-9']*")
152:    """Actually compile, audit axioms, recheck kernel and independently extract."""
195:        if not extraction.get("ok") or not extraction.get("compiles_alone") or not all(extraction.get("faithful", {}).values()):
203:        if isinstance(exc, (subprocess.TimeoutExpired, TimeoutError)):
210:    """Native subscription credentials/status need owner intervention."""
232:def client_name(config):
306:        raise ValueError("unsupported scientist client")
326:                raise NativeAuthenticationError("native subscription credential file missing; owner login required")
328:    version = subprocess.check_output([str(binary), "--version"], text=True).strip()
331:    libraries = sorted(Path(library_root).resolve().glob(".lake/packages/*/.lake/build/lib/lean"))
334:    if (Path(library_root) / "lake-manifest.json").read_bytes() != (ROOT / "lake-manifest.json").read_bytes():
336:    subprocess.run(["docker", "image", "inspect", IMAGE], check=True, capture_output=True)
339:              "client_binary": str(binary), "client_version": version, "client_sha256": digest(binary),
342:              "lean_version": subprocess.check_output([str(lean / "bin/lean"), "--version"], text=True).strip()}
345:        config.update(codex=str(binary), codex_version=version, codex_sha256=config["client_sha256"],
351:    agent = client_name(config)
354:                      client_binary=config.get("client_binary", config.get("codex")),
355:                      client_version=config.get("client_version", config.get("codex_version")),
356:                      client_sha256=config.get("client_sha256", config.get("codex_sha256")),
368:    agent = client_name(config)
370:        raise ValueError("unsupported scientist client")
371:    binary = config.get("client_binary", config.get("codex"))
372:    expected = config.get("client_sha256", config.get("codex_sha256"))
395:           "--env", "VAS_LEAN=/opt/lean/bin/lean", "--env", "PATH=/opt/lean/bin:/usr/local/bin:/usr/bin:/bin", "--workdir", "/work", "--entrypoint", "/harness/entrypoint.sh",
406:        cmd += mount(lib, f"/harness/.lake/packages/{package}/.lake/build/lib/lean")
408:        if client_name(config) == "claude":
409:            cmd += mount(config["client_binary"], "/usr/local/bin/claude")
460:            result = run_container(cmd, stdout=log, stderr=subprocess.STDOUT, timeout=3000)
465:    except subprocess.TimeoutExpired:
474:    provenance["library_manifest_sha256"] = digest(ROOT / "lake-manifest.json")
487:    """Always stop the named container, including client timeout/interruption."""
491:        return subprocess.run(cmd, **kwargs)
493:        subprocess.run(["docker", "rm", "-f", ident], capture_output=True, timeout=30)
496:def claude_subscription_status(returncode, output):
497:    """Parse subscription status without retaining native account/profile fields."""
506:def ensure_subscription(config, work):
508:    if client_name(config) == "claude":
514:    if client_name(config) == "claude":
515:        valid = claude_subscription_status(login.returncode, login.stdout)
521:        raise NativeAuthenticationError(f"native {label} subscription login required; no API fallback")
525:    agent = client_name(config)
540:    Match structured client error fields, not arbitrary scientific/tool text.
553:                return "Claude reported a client error"
562:                    return "Claude did not complete successfully (auth, quota, turn limit or client error)"
573:        return "Claude did not complete successfully (auth, quota, turn limit or client error)"
579:def client_failure_kind(trace, agent):
587:                # Native clients sometimes fail before emitting JSON.
640:        ensure_subscription(state["runtime"], work)
666:            proc = run_container(cmd, input=prompt, text=True, stdout=log, stderr=subprocess.STDOUT, timeout=7200)
667:        failure_kind = client_failure_kind(trace, client_name(state["runtime"]))
669:            failure = f"{client_name(state['runtime'])} reported native {failure_kind} failure"
671:            failure = f"{client_name(state['runtime'])} exited {proc.returncode}"
672:        elif client_name(state["runtime"]) == "claude":
677:            state["failure_kind"] = failure_kind or "client"
686:    except subprocess.TimeoutExpired:
688:        state["error"] = f"{client_name(state['runtime'])} timeout; raw trace retained"
703:    """Retry real checking failures; stop on human/input or client failure."""
772:        click.echo(json.dumps({"vcs_client_failure": True, "agent": agent, "failure_kind": "authentication"}))
805:@click.option("--agent", type=click.Choice(["codex", "claude"]), help="Must match the recorded run client; defaults to that client")
810:    if agent and agent != client_name(state["runtime"]):
shell input
{
  "command": "/usr/bin/bash -lc \"ls -la /harness/.lake/packages; find /harness/.lake -name '*Deriv*' -o -name '*MeanValue*' -o -name '*Log*' | head -40; sed -n '150,205p' /harness/src/vcs_protocol.py; sed -n '170,230p' /harness/src/vcs_lean.py\""
}
shell output · exit 0
total 40
drwxr-xr-x 10 root root 4096 Nov 17 14:13 .
drwxr-xr-x  3 root root 4096 Nov 17 14:13 ..
drwxr-xr-x  3 root root 4096 Nov 17 14:13 LeanSearchClient
drwxr-xr-x  3 root root 4096 Nov 17 14:13 Qq
drwxr-xr-x  3 root root 4096 Nov 17 14:13 aesop
drwxr-xr-x  3 root root 4096 Nov 17 14:13 batteries
drwxr-xr-x  3 root root 4096 Nov 17 14:13 importGraph
drwxr-xr-x  3 root root 4096 Nov 17 14:13 mathlib
drwxr-xr-x  3 root root 4096 Nov 17 14:13 plausible
drwxr-xr-x  3 root root 4096 Nov 17 14:13 proofwidgets
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.olean.server
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.trace
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.ilean.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.olean
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.olean.server
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.olean.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.olean
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.ir
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.ir.sig.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.olean.private
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.ilean.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.olean.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.olean.private.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.ir.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.olean.server.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.ir.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.ir.sig
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.ir.sig
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.olean.server.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.ir.sig.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.trace
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.olean.private
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.olean.private.hash
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveShrinkable.ilean
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.ilean
/harness/.lake/packages/plausible/.lake/build/lib/lean/Plausible/DeriveArbitrary.ir
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.ir.sig.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.ir.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.olean.private
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.ir
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.ilean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.olean.private.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.ilean.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.olean.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.trace
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.olean.server.hash
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.olean.server
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Data/Nat/Log.ir.sig
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Basic/Logic

def verify_candidate(work, manifest, out):
    """Actually compile, audit axioms, recheck kernel and independently extract."""
    from vcs_lean import ALLOWED_AXIOMS, LISTER, listed
    from vcs_extract import run_lean, main as extract
    out = Path(out)
    out.mkdir(parents=True, exist_ok=True)
    result = {"ok": False, "check_complete": False, "reviewable": False, "verdict": "not_proved", "time": stamp()}
    try:
        m, proof, narrative = load_candidate(work, manifest)
        snapshot = out / "submitted.lean"
        snapshot.write_bytes(proof.read_bytes())
        (out / "submitted-report.txt").write_bytes(narrative.read_bytes())
        write_json(out / "submitted-candidate.json", m)
        proof = snapshot
        names = list(m["conclusions"].values())
        source = proof.read_text()
        validate_source(source, names)
        targets = "[" + ", ".join("``" + n for n in names) + "]"
        audited = out / "Checked.lean"
        audited.write_text(source + "\n" + "\n".join(f"#print axioms {n}" for n in names) + "\n" + LISTER.replace("ROOTS", targets))
        status, log = run_lean(audited)
        (out / "lean.log").write_text(log)
        result["lean_exit"] = status
        additions = listed(log)
        seen = set(re.findall(r"^'(.+)' (?:depends on axioms:|does not depend on any axioms)", log, re.M))
        axioms = {n: [a.strip() for a in xs.split(",") if a.strip()]
                  for n, xs in re.findall(r"^'(.+)' depends on axioms: \[([^\]]*)\]", log, re.M)}
        unexpected = {a for xs in axioms.values() for a in xs if a not in ALLOWED_AXIOMS}
        disclosed = {a["name"] for a in additions or [] if a["kind"] == "axiom" and a["used"]}
        gaps = [a for a in additions or [] if a["kind"] == "gap" and a["used"]]
        if status != 0 or additions is None or not set(names) <= seen:
            raise ValueError("Lean, kernel recheck or axiom audit failed; see lean.log")
        if any(a not in disclosed and not (a == "sorryAx" and gaps) for a in unexpected):
            raise ValueError("undisclosed axioms")
        if re.search(r"VAS_UNSTATED \S+ used=true", log) or any("⋯" in a["statement"] for a in additions if a["used"]):
            raise ValueError("incomplete assumption disclosure")
        # click's standalone_mode=False gives real exit errors without terminating host.
        try:
            extract.main(args=[str(proof), *sum((["--theorem", n] for n in names), []), "--out", str(out / "extracted")], standalone_mode=False)
        except SystemExit as exc:
            # Extractor explicitly sys.exit(0), even outside standalone mode.
            if exc.code != 0:
                raise ValueError("independent extraction failed") from exc
        extraction = read_json(out / "extracted.json")
        if not extraction.get("ok") or not extraction.get("compiles_alone") or not all(extraction.get("faithful", {}).values()):
            raise ValueError("independent extraction/statement comparison failed")
        # Any added premise or gap, even unused, remains explicitly conditional.
        result |= {"ok": not additions, "check_complete": True, "reviewable": True, "verdict": "proved_if" if additions else "proved",
                   "added_assumptions": additions, "conditional_on": sorted(unexpected),
                   "extraction": extraction, "scientific_relevance": "requires human review"}
    except (Exception, SystemExit) as exc:
        result |= {"ok": False, "error": str(exc) or type(exc).__name__}
        if isinstance(exc, (subprocess.TimeoutExpired, TimeoutError)):
            result["verdict"] = "no_verdict"
    write_json(out / "verdict.json", result)
shell input
{
  "command": "/usr/bin/bash -lc \"find /harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib -name '*MeanValue*.olean' -o -name '*Log*Deriv*.olean' -o -name '*Log*Basic*.olean' -o -name '*Deriv*Basic*.olean'; sed -n '15,60p' /harness/src/vcs_extract.py\""
}
shell output · exit 0
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/MeanValue.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/MeanValue.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/LogDeriv.olean

# Display text omits implicit arguments, types and sometimes whole subterms.
# Compare the complete kernel expressions instead. Binder names and metadata do
# not affect meaning; remove them so source positions and fresh binder names do
# not make an otherwise identical extraction fail. All constants, universe
# levels, implicit arguments and binder information remain in the identity.
IDENTITY = """
private partial def VAS_identityExpr : Lean.Expr → Lean.Expr
  | .mdata _ value => VAS_identityExpr value
  | .app fn arg => .app (VAS_identityExpr fn) (VAS_identityExpr arg)
  | .lam _ typ body info => .lam .anonymous (VAS_identityExpr typ) (VAS_identityExpr body) info
  | .forallE _ typ body info => .forallE .anonymous (VAS_identityExpr typ) (VAS_identityExpr body) info
  | .letE _ typ value body flag => .letE .anonymous (VAS_identityExpr typ) (VAS_identityExpr value) (VAS_identityExpr body) flag
  | .proj owner idx value => .proj owner idx (VAS_identityExpr value)
  | value => value

private def VAS_declarationIdentity (ci : Lean.ConstantInfo) : String :=
  let kind := match ci with
    | .axiomInfo _ => "axiom"
    | .defnInfo _ => "definition"
    | .thmInfo _ => "theorem"
    | .opaqueInfo _ => "opaque"
    | .quotInfo _ => "quotient"
    | .inductInfo info => s!"inductive {info.numParams} {info.numIndices} {reprStr info.ctors}"
    | .ctorInfo info => s!"constructor {info.induct} {info.cidx} {info.numParams} {info.numFields}"
    | .recInfo info => s!"recursor {info.numParams} {info.numIndices} {info.numMotives} {info.numMinors}"
  let value := match ci.value? with
    | some body => reprStr (VAS_identityExpr body)
    | none => "no value"
  s!"{kind}|levels={reprStr ci.levelParams}|type={reprStr (VAS_identityExpr ci.type)}|value={value}"
"""

REACH = """
open Lean Elab Command Meta in
run_cmd do
  let kenv := (← getEnv).checked.get
  let localSet : NameSet := kenv.constants.map₂.toList.foldl (fun s (n, _) => s.insert n) {}
  -- statements only: from each conclusion's type, through definitions' types and values
  let mut seen : NameSet := {}
  let mut todo : List Name := []
  for t in TARGETS do
    let some ci := kenv.find? t | throwError m!"no theorem {t}"
    todo := ci.type.getUsedConstants.toList ++ todo
    logInfo m!"VAS_CONCLUSION {t} : {← liftTermElabM <| ppExpr ci.type} VAS_END"
    logInfo m!"VAS_ORIGINAL_IDENTITY {t} : {reprStr (VAS_identityExpr ci.type)} VAS_END"
  while !todo.isEmpty do
shell input
{
  "command": "/usr/bin/bash -lc \"find /harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/SpecialFunctions/Log -name '*.olean'; grep -nA18 'def run_lean' /harness/src/vcs_extract.py\""
}
shell output · exit 0
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/SpecialFunctions/Log/Deriv.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/SpecialFunctions/Log/Basic.olean
100:def run_lean(path):
101-    """Lean, then leanchecker on the compiled module (OT-1861): a nonzero status if either fails."""
102-    libs = sorted((ROOT / ".lake/packages").glob("*/.lake/build/lib/lean"))
103-    env = dict(os.environ, LEAN_PATH=":".join(map(str, libs)), LEAN_NUM_THREADS="1")
104-    with tempfile.TemporaryDirectory(prefix="vcs-olean-") as build:
105-        r = subprocess.run([LEAN, "-j1", f"--root={Path(path).resolve().parent}", "-o", str(Path(build) / "VasExtract.olean"), str(path)], cwd=ROOT,
106-                           env=env, capture_output=True, text=True, timeout=900)
107-        if r.returncode != 0:
108-            return r.returncode, r.stdout + r.stderr
109-        c = subprocess.run([LEANCHECKER, "VasExtract"], cwd=ROOT, capture_output=True, text=True, timeout=900,
110-                           env=dict(env, LEAN_PATH=env["LEAN_PATH"] + ":" + build,
111-                                    PATH=str(Path(LEAN).parent) + ":" + env.get("PATH", "")))
112-        note = f"\nleanchecker exit {c.returncode}\n{(c.stdout + c.stderr)[-1500:]}\n"
113-        return (0 if c.returncode == 0 else 10), r.stdout + r.stderr + note
114-
115-
116-def expression_identities(text, marker):
117-    """Read complete expression records; duplicate/missing records fail closed."""
118-    records = re.findall(r"^" + re.escape(marker) + r" (\S+) : (.*?) VAS_END", text, re.M | re.S)
shell input
{
  "command": "/usr/bin/bash -lc \"mkdir -p history/cycle1; cp Model.lean candidate.json report.txt human-feedback.json history/cycle1/; python - <<'PY'\nfrom pathlib import Path\npaths=list(Path('/harness/.lake/packages').glob('*/.lake/build/lib/lean'))\nPath('/work/lean-env.sh').write_text('export LEAN_PATH='+':'.join(map(str,paths))+'\\\\n')\nPY\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"cat > diagnostics/probe.lean <<'EOF'\nimport Mathlib.Analysis.SpecialFunctions.Log.Deriv\nimport Mathlib.Analysis.Calculus.Deriv.MeanValue\nimport Mathlib.Tactic.Linarith\nimport Mathlib.Tactic.FieldSimp\nimport Mathlib.Tactic.Ring\n#check monotoneOn_of_hasDerivWithinAt_nonneg\n#check monotoneOn_of_deriv_nonneg\n#check strictMonoOn_of_deriv_pos\n#check is_const_of_deriv_eq_zero\n#check Convex.eqOn_of_derivWithin_eq\n#check Convex.monotoneOn_of_deriv_nonneg\n#check Convex.monotoneOn_of_hasDerivWithinAt_nonneg\n#check HasDerivAt.log\n#check hasDerivAt_id\n#check HasDerivAt.const_mul\n#check HasDerivAt.div_const\n#check Convex.eqOn_of_hasDerivWithinAt_eq\n#check eq_of_hasDerivAt_eq_on_Icc\n#check eq_of_hasDerivAt_eq_on_Ioo\n#check HasDerivAt.mono\n#check Convex.eqOn_of_deriv_eq\n#check HasDerivAt.deriv\nEOF\nsource lean-env.sh\n/opt/lean/bin/lean diagnostics/probe.lean > diagnostics/probe.log 2>&1\ncat diagnostics/probe.log\""
}
shell output · exit 0
monotoneOn_of_hasDerivWithinAt_nonneg {D : Set ℝ} (hD : Convex ℝ D) {f f' : ℝ → ℝ} (hf : ContinuousOn f D)
  (hf' : ∀ x ∈ interior D, HasDerivWithinAt f (f' x) (interior D) x) (hf'₀ : ∀ x ∈ interior D, 0 ≤ f' x) :
  MonotoneOn f D
monotoneOn_of_deriv_nonneg {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ} (hf : ContinuousOn f D)
  (hf' : DifferentiableOn ℝ f (interior D)) (hf'_nonneg : ∀ x ∈ interior D, 0 ≤ deriv f x) : MonotoneOn f D
strictMonoOn_of_deriv_pos {D : Set ℝ} (hD : Convex ℝ D) {f : ℝ → ℝ} (hf : ContinuousOn f D)
  (hf' : ∀ x ∈ interior D, 0 < deriv f x) : StrictMonoOn f D
is_const_of_deriv_eq_zero.{u_3, u_4} {𝕜 : Type u_3} {G : Type u_4} [RCLike 𝕜] [NormedAddCommGroup G] [NormedSpace 𝕜 G]
  {f : 𝕜 → G} (hf : Differentiable 𝕜 f) (hf' : ∀ (x : 𝕜), deriv f x = 0) (x y : 𝕜) : f x = f y
diagnostics/probe.lean:10:7: error(lean.unknownIdentifier): Unknown constant `Convex.eqOn_of_derivWithin_eq`
diagnostics/probe.lean:11:7: error(lean.unknownIdentifier): Unknown constant `Convex.monotoneOn_of_deriv_nonneg`
diagnostics/probe.lean:12:7: error(lean.unknownIdentifier): Unknown constant `Convex.monotoneOn_of_hasDerivWithinAt_nonneg`
HasDerivAt.log {f : ℝ → ℝ} {x f' : ℝ} (hf : HasDerivAt f f' x) (hx : f x ≠ 0) :
  HasDerivAt (fun y => Real.log (f y)) (f' / f x) x
hasDerivAt_id.{u} {𝕜 : Type u} [NontriviallyNormedField 𝕜] (x : 𝕜) : HasDerivAt id 1 x
HasDerivAt.const_mul.{u, u_3} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {x : 𝕜} {𝔸 : Type u_3} [NormedRing 𝔸]
  [NormedAlgebra 𝕜 𝔸] {d : 𝕜 → 𝔸} {d' : 𝔸} (c : 𝔸) (hd : HasDerivAt d d' x) : HasDerivAt (fun y => c * d y) (c * d') x
HasDerivAt.div_const.{u, u_2} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {x : 𝕜} {𝕜' : Type u_2} [NormedDivisionRing 𝕜']
  [NormedAlgebra 𝕜 𝕜'] {c : 𝕜 → 𝕜'} {c' : 𝕜'} (hc : HasDerivAt c c' x) (d : 𝕜') :
  HasDerivAt (fun x => c x / d) (c' / d) x
diagnostics/probe.lean:17:7: error(lean.unknownIdentifier): Unknown constant `Convex.eqOn_of_hasDerivWithinAt_eq`
diagnostics/probe.lean:18:7: error(lean.unknownIdentifier): Unknown identifier `eq_of_hasDerivAt_eq_on_Icc`
diagnostics/probe.lean:19:7: error(lean.unknownIdentifier): Unknown identifier `eq_of_hasDerivAt_eq_on_Ioo`
diagnostics/probe.lean:20:7: error(lean.unknownIdentifier): Unknown constant `HasDerivAt.mono`
diagnostics/probe.lean:21:7: error(lean.unknownIdentifier): Unknown constant `Convex.eqOn_of_deriv_eq`
HasDerivAt.deriv.{u, v} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {F : Type v} [NormedAddCommGroup F] [NormedSpace 𝕜 F]
  {f : 𝕜 → F} {f' : F} {x : 𝕜} (h : HasDerivAt f f' x) : deriv f x = f'
assistant
The revised model predicts that adding the salt now, at 20 °C, minimizes the time if the salt starts at or below 20 °C and dissolution absorbs heat. The reason is that cooling the mixture reduces losses to the room while the heater continues supplying power. This remains conditional on the shared heat-loss law, rapid dissolution and negligible evaporation; the supplied information gives no numerical boiling time. I’m formalizing both the power change and the timing comparison.
shell input
{
  "command": "/usr/bin/bash -lc \"cat > Model.lean <<'EOF'\nimport Mathlib.Analysis.SpecialFunctions.Log.Deriv\nimport Mathlib.Analysis.Calculus.Deriv.MeanValue\nimport Mathlib.Tactic.Linarith\nimport Mathlib.Tactic.FieldSimp\nimport Mathlib.Tactic.Ring\n\n/- Supplied starting temperature in degrees Celsius. -/\ndef initialTemperature : ℝ := 20\n\n/- Constant heater input W, room temperature A, linear heat-loss\n   coefficient k. This SAME law applies to water and brine (watts). -/\ndef netPower (W k A T : ℝ) : ℝ := W - k * (T - A)\n\n/- Instantaneous conservation of energy on adding salt: C is water+pot\n   capacity, S the additional capacity, Ts salt temperature, H dissolution\n   energy absorbed. Capacities J/K, H joules. -/\ndef mixedTemperature (C S H Ts x : ℝ) : ℝ :=\n  (C * x + S * Ts - H) / (C + S)\n\n/- Integrated inverse energy balance dt/dT = capacity/netPower(T).\n   Used only where net power is positive and k>0. -/\ndef heatingTime (capacity W k A u v : ℝ) : ℝ :=\n  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))\n\n/- Total seconds to a fixed final solution boiling temperature B when\n   salt is added at unsalted temperature x. The initial cooling and the\n   changed heat capacity are both included. -/\ndef boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=\n  heatingTime C W k A initialTemperature x +\n  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B\n\n/- Derive the mixing balance rather than assuming a cooling amount. -/\nlemma mixing_balance :\n    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →\n    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by\n  intro C S H Ts x hc\n  unfold mixedTemperature\n  field_simp\n\n/- Derive the net-power jump from energy conservation AND the shared\n   heat-transfer law; before/after powers are not independent parameters. -/\nlemma power_change :\n    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →\n    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =\n      k * (S * (x - Ts) + H) / (C + S) := by\n  intro C S H Ts W k A x hc\n  unfold netPower mixedTemperature\n  field_simp\n  <;> ring\n\nlemma power_derivative :\n    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by\n  intro W k A x\n  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;>\n    simp [netPower]\n\n/- Checks the integrated heating law against the differential first law:\n   increasing endpoint temperature costs capacity/netPower seconds/K. -/\nlemma heating_time_derivative :\n    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →\n    HasDerivAt (fun y => heatingTime capacity W k A u y)\n      (capacity / netPower W k A v) v := by\n  intro capacity W k A u v hk hv\n  have h := (((power_derivative W k A v).log hv).const_sub\n    (Real.log (netPower W k A u))).const_mul (capacity / k)\n  convert h using 1\n  · field_simp\n    <;> ring\n\n/- Eliminate the two heating stages. The derivative compares the time\n   spent heating unsalted water with the time saved in the salted stage. -/\nlemma boiling_time_derivative :\n    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →\n    netPower W k A x ≠ 0 →\n    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →\n    HasDerivAt (boilingTime C S H Ts B W k A)\n      (C / netPower W k A x -\n       C / netPower W k A (mixedTemperature C S H Ts x)) x := by\n  intro C S H Ts B W k A x hc hk hx hz\n  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by\n    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const\n      (C + S) using 1 <;> simp [mixedTemperature]\n  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm\n  have hpost := (((hn.log hz).sub_const\n    (Real.log (netPower W k A B))).const_mul ((C + S) / k))\n  have hpre := heating_time_derivative C W k A initialTemperature x hk hx\n  convert hpre.add hpost using 1\n  · field_simp\n    <;> ring\n\n/- Positive net power up to B, cool salt, and nonnegative dissolution cost\n   imply cooling on mixing, hence an increase of net power at that instant.\n   The heat-transfer coefficient itself has NOT been increased by salt. -/\nlemma power_order :\n    ∀ (C S H Ts B W k A x : ℝ),\n    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →\n    0 < k → 0 < netPower W k A B →\n    initialTemperature ≤ x → x ≤ B →\n    0 < netPower W k A x ∧\n    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by\n  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB\n  have hc : 0 < C + S := by linarith\n  have hcool : 0 ≤ S * (x - Ts) + H :=\n    add_nonneg (mul_nonneg hS (by linarith)) hH\n  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)\n  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=\n    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)\n  have hp : 0 < netPower W k A x := by\n    unfold netPower at *\n    nlinarith\n  exact ⟨hp, by linarith⟩\n\n/- Scientific answer: in this explicit Newton-loss model immediate\n   addition (20 C, elapsed time zero) is a global weak minimum over\n   admissible later additions. Also expose the derived power jump. -/\ntheorem addition_timing_answer :\n    ∀ (C S H Ts B W k A x : ℝ),\n    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →\n    0 < k → 0 < netPower W k A B →\n    initialTemperature ≤ x → x ≤ B →\n    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =\n      k * (S * (x - Ts) + H) / (C + S)) ∧\n    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧\n    (boilingTime C S H Ts B W k A initialTemperature ≤\n      boilingTime C S H Ts B W k A x) ∧\n    (heatingTime C W k A initialTemperature initialTemperature = 0) := by\n  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB\n  have hc : 0 < C + S := by linarith\n  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB\n  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩\n  · have hd : ∀ y ∈ Set.Icc initialTemperature B,\n        HasDerivAt (boilingTime C S H Ts B W k A)\n          (C / netPower W k A y -\n           C / netPower W k A (mixedTemperature C S H Ts y)) y := by\n      intro y hy\n      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2\n      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)\n        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))\n    have hm : MonotoneOn (boilingTime C S H Ts B W k A)\n        (Set.Icc initialTemperature B) := by\n      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)\n      · intro y hy\n        exact (hd y hy).continuousAt.continuousWithinAt\n      · intro y hy\n        exact (hd y (Set.mem_of_mem_interior hy)).hasDerivWithinAt\n      · intro y hy\n        have hmem := Set.mem_of_mem_interior hy\n        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2\n        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=\n          lt_of_lt_of_le ho.1 ho.2\n        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤\n            C / netPower W k A y := by\n          apply (div_le_div_iff₀ hz ho.1).2\n          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)\n        linarith\n    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix\n  · unfold heatingTime\n    rw [sub_self, mul_zero]\nEOF\nsource lean-env.sh\n/opt/lean/bin/lean Model.lean > diagnostics/cycle2-compile-1.log 2>&1\""
}
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc \"cat diagnostics/cycle2-compile-1.log; cat > diagnostics/probe2.lean <<'EOF'\nimport Mathlib.Analysis.Calculus.Deriv.MeanValue\n#check eqOn_of_hasDerivWithinAt_eq_zero\n#check eqOn_of_derivWithin_eq_zero\n#check is_const_of_deriv_eq_zero\n#check Convex.is_const_of_fderivWithin_eq_zero\n#check Convex.eqOn_of_hasFDerivWithinAt_eq\n#check eq_of_hasDerivAt_eq_zero\n#check eq_of_deriv_eq_zero\n#check Convex.eq_of_hasFDerivWithinAt_eq\n#check HasDerivAt.const_sub\n#check HasDerivAt.congr_deriv\nEOF\nsource lean-env.sh\n/opt/lean/bin/lean diagnostics/probe2.lean > diagnostics/probe2.log 2>&1\""
}
shell output · exit 1 · failed
Model.lean:17:4: error(lean.dependsOnNoncomputable): failed to compile definition, consider marking it as 'noncomputable' because it depends on 'Real.instDivInvMonoid', which is 'noncomputable'
Model.lean:22:4: error(lean.dependsOnNoncomputable): failed to compile definition, consider marking it as 'noncomputable' because it depends on 'Real.instDivInvMonoid', which is 'noncomputable'
Model.lean:28:4: error(lean.dependsOnNoncomputable): failed to compile definition, consider marking it as 'noncomputable' because it depends on 'heatingTime', which is 'noncomputable'
Model.lean:49:2: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:49:2: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
Model.lean:52:59: error: unsolved goals
case e'_8
W k A x : ℝ
⊢ netPower W k A = fun x => W - k * (x - A)
Model.lean:55:10: warning: This simp argument is unused:
  netPower

Hint: Omit it from the simp argument list.
  [apply] simp

Note: This linter can be disabled with `set_option linter.unusedSimpArgs false`
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
Model.lean:67:2: error: unsolved goals
case e'_8
capacity W k A u v : ℝ
hk : k ≠ 0
hv : netPower W k A v ≠ 0
h :
  HasDerivAt (fun y => capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A y)))
    (capacity / k * -(-k / netPower W k A v)) v
⊢ (fun y => heatingTime capacity W k A u y) = fun y =>
    capacity * Real.log (netPower W k A u) * k⁻¹ - capacity * Real.log (netPower W k A y) * k⁻¹
Model.lean:62:41: error: unsolved goals
case e'_9
capacity W k A u v : ℝ
hk : k ≠ 0
hv : netPower W k A v ≠ 0
h :
  HasDerivAt (fun y => capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A y)))
    (capacity / k * -(-k / netPower W k A v)) v
⊢ capacity / netPower W k A v = capacity / k * -(-k / netPower W k A v)
Model.lean:80:70: error: unsolved goals
case e'_8
C S H Ts B W k A x : ℝ
hc : C + S ≠ 0
hk : k ≠ 0
hx : netPower W k A x ≠ 0
hz : netPower W k A (mixedTemperature C S H Ts x) ≠ 0
⊢ mixedTemperature C S H Ts = fun x => (C * x + S * Ts - H) / (C + S)
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
Model.lean:88:2: error: unsolved goals
case e'_8
C S H Ts B W k A x : ℝ
hc : C + S ≠ 0
hk : k ≠ 0
hx : netPower W k A x ≠ 0
hz : netPower W k A (mixedTemperature C S H Ts x) ≠ 0
hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x
hn : HasDerivAt (netPower W k A ∘ mixedTemperature C S H Ts) (-k * (C / (C + S))) x
hpost :
  HasDerivAt
    (fun y => (C + S) / k * (Real.log ((netPower W k A ∘ mixedTemperature C S H Ts) y) - Real.log (netPower W k A B)))
    ((C + S) / k * (-k * (C / (C + S)) / (netPower W k A ∘ mixedTemperature C S H Ts) x)) x
hpre : HasDerivAt (fun y => heatingTime C W k A initialTemperature y) (C / netPower W k A x) x
⊢ boilingTime C S H Ts B W k A =
    (fun y => heatingTime C W k A initialTemperature y) + fun y =>
      C * Real.log ((netPower W k A ∘ mixedTemperature C S H Ts) y) * k⁻¹ - C * Real.log (netPower W k A B) * k⁻¹ +
          S * Real.log ((netPower W k A ∘ mixedTemperature C S H Ts) y) * k⁻¹ -
        S * Real.log (netPower W k A B) * k⁻¹
Model.lean:78:62: error: unsolved goals
case e'_9
C S H Ts B W k A x : ℝ
hc : C + S ≠ 0
hk : k ≠ 0
hx : netPower W k A x ≠ 0
hz : netPower W k A (mixedTemperature C S H Ts x) ≠ 0
hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x
hn : HasDerivAt (netPower W k A ∘ mixedTemperature C S H Ts) (-k * (C / (C + S))) x
hpost :
  HasDerivAt
    (fun y => (C + S) / k * (Real.log ((netPower W k A ∘ mixedTemperature C S H Ts) y) - Real.log (netPower W k A B)))
    ((C + S) / k * (-k * (C / (C + S)) / (netPower W k A ∘ mixedTemperature C S H Ts) x)) x
hpre : HasDerivAt (fun y => heatingTime C W k A initialTemperature y) (C / netPower W k A x) x
⊢ C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
    C / netPower W k A x + (C + S) / k * (-k * (C / (C + S)) / (netPower W k A ∘ mixedTemperature C S H Ts) x)
Model.lean:82:32: warning: This simp argument is unused:
  mixedTemperature

Hint: Omit it from the simp argument list.
  [apply] simp

Note: This linter can be disabled with `set_option linter.unusedSimpArgs false`
Model.lean:145:21: error(lean.unknownIdentifier): Unknown constant `Set.mem_of_mem_interior`
Model.lean:147:21: error(lean.unknownIdentifier): Unknown constant `Set.mem_of_mem_interior`
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='Model.lean'\ns=open(p).read().replace('def mixedTemperature','noncomputable def mixedTemperature').replace('def heatingTime','noncomputable def heatingTime').replace('def boilingTime','noncomputable def boilingTime')\ns=s.replace('  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;>\\\\n    simp [netPower]','  unfold netPower\\\\n  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp')\ns=s.replace('  convert h using 1\\\\n  · field_simp\\\\n    <;> ring','  unfold heatingTime\\\\n  convert h using 1\\\\n  field_simp [hk, hv]\\\\n  <;> ring')\ns=s.replace('    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const\\\\n      (C + S) using 1 <;> simp [mixedTemperature]','    unfold mixedTemperature\\\\n    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const\\\\n      (C + S) using 1 <;> simp')\ns=s.replace('  convert hpre.add hpost using 1\\\\n  · field_simp\\\\n    <;> ring','  convert hpre.add hpost using 1\\\\n  · rfl\\\\n  · dsimp only [Function.comp_apply]\\\\n    field_simp [hc, hk, hx, hz]\\\\n    <;> ring')\ns=s.replace('Set.mem_of_mem_interior hy','interior_subset hy')\nopen(p,'w').write(s)\nPY\nsource lean-env.sh\n/opt/lean/bin/lean Model.lean > diagnostics/cycle2-compile-2.log 2>&1\ncat diagnostics/cycle2-compile-2.log\ncat diagnostics/probe2.log\""
}
shell output · exit 0
Model.lean:49:2: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:49:2: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
Model.lean:69:2: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:69:6: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:69:6: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
Model.lean:93:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:93:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
diagnostics/probe2.lean:2:7: error(lean.unknownIdentifier): Unknown identifier `eqOn_of_hasDerivWithinAt_eq_zero`
diagnostics/probe2.lean:3:7: error(lean.unknownIdentifier): Unknown identifier `eqOn_of_derivWithin_eq_zero`
diagnostics/probe2.lean:4:7: error(lean.unknownIdentifier): Unknown identifier `is_const_of_deriv_eq_zero`
diagnostics/probe2.lean:5:7: error(lean.unknownIdentifier): Unknown constant `Convex.is_const_of_fderivWithin_eq_zero`
diagnostics/probe2.lean:6:7: error(lean.unknownIdentifier): Unknown constant `Convex.eqOn_of_hasFDerivWithinAt_eq`
diagnostics/probe2.lean:7:7: error(lean.unknownIdentifier): Unknown identifier `eq_of_hasDerivAt_eq_zero`
diagnostics/probe2.lean:8:7: error(lean.unknownIdentifier): Unknown identifier `eq_of_deriv_eq_zero`
diagnostics/probe2.lean:9:7: error(lean.unknownIdentifier): Unknown constant `Convex.eq_of_hasFDerivWithinAt_eq`
HasDerivAt.const_sub.{u, v} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {F : Type v} [NormedAddCommGroup F]
  [NormedSpace 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (c : F) (hf : HasDerivAt f f' x) :
  HasDerivAt (fun x => c - f x) (-f') x
HasDerivAt.congr_deriv.{u, v} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {F : Type v} [NormedAddCommGroup F]
  [NormedSpace 𝕜 F] {f : 𝕜 → F} {f' g' : F} {x : 𝕜} (h : HasDerivAt f f' x) (h' : f' = g') : HasDerivAt f g' x
web_search input
{
  "query": "https://bpb-us-e1.wpmucdn.com/sites.mit.edu/dist/6/1810/files/2020/08/AHTTv510.pdf",
  "action": {
    "type": "open_page",
    "url": "https://bpb-us-e1.wpmucdn.com/sites.mit.edu/dist/6/1810/files/2020/08/AHTTv510.pdf"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "ref_id": "turn2view0",
      "title": "Internal Error"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn2view1",
      "snippet": "Total lines: 154",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/t-Qh1-m1aRbhZ8WFZdsjQIGpXQmbor4umCdUus9NyuTZbpqm1YjHzVb-iNQcpcS8baxMTgtMVt_LQy6BbrSWZG33dENR_sVS4uLAEehAURbmGXtbWG4O-VwUSFX27UTmg4lMBFVEIJiv3uJmEi3alQ",
      "title": "11.1 The Dissolution Process - Chemistry 2e | OpenStax",
      "url": "https://openstax.org/books/chemistry-2e/pages/11-1-the-dissolution-process"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat diagnostics/probe2.log; cat diagnostics/cycle2-compile-2.log'"
}
shell output · exit 0
diagnostics/probe2.lean:2:7: error(lean.unknownIdentifier): Unknown identifier `eqOn_of_hasDerivWithinAt_eq_zero`
diagnostics/probe2.lean:3:7: error(lean.unknownIdentifier): Unknown identifier `eqOn_of_derivWithin_eq_zero`
diagnostics/probe2.lean:4:7: error(lean.unknownIdentifier): Unknown identifier `is_const_of_deriv_eq_zero`
diagnostics/probe2.lean:5:7: error(lean.unknownIdentifier): Unknown constant `Convex.is_const_of_fderivWithin_eq_zero`
diagnostics/probe2.lean:6:7: error(lean.unknownIdentifier): Unknown constant `Convex.eqOn_of_hasFDerivWithinAt_eq`
diagnostics/probe2.lean:7:7: error(lean.unknownIdentifier): Unknown identifier `eq_of_hasDerivAt_eq_zero`
diagnostics/probe2.lean:8:7: error(lean.unknownIdentifier): Unknown identifier `eq_of_deriv_eq_zero`
diagnostics/probe2.lean:9:7: error(lean.unknownIdentifier): Unknown constant `Convex.eq_of_hasFDerivWithinAt_eq`
HasDerivAt.const_sub.{u, v} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {F : Type v} [NormedAddCommGroup F]
  [NormedSpace 𝕜 F] {f : 𝕜 → F} {f' : F} {x : 𝕜} (c : F) (hf : HasDerivAt f f' x) :
  HasDerivAt (fun x => c - f x) (-f') x
HasDerivAt.congr_deriv.{u, v} {𝕜 : Type u} [NontriviallyNormedField 𝕜] {F : Type v} [NormedAddCommGroup F]
  [NormedSpace 𝕜 F] {f : 𝕜 → F} {f' g' : F} {x : 𝕜} (h : HasDerivAt f f' x) (h' : f' = g') : HasDerivAt f g' x
Model.lean:49:2: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:49:2: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
Model.lean:69:2: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:69:6: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:69:6: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
Model.lean:93:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:93:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='Model.lean'\ns=open(p).read()\nmarker='/- Eliminate the two heating stages.'\naddition='''/- Derivation of the stage-time formula from the inverse first law.\n   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,\n   the endpoint time MUST equal heatingTime; it is not a fitted formula.\n   Endpoint derivatives may be read as those of a smooth local extension. -/\nlemma stage_time_from_energy :\n    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),\n    u ≤ v → k ≠ 0 →\n    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →\n    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →\n    f u = 0 → f v = heatingTime capacity W k A u v := by\n  intro capacity W k A u v f huv hk hp hf hu\n  have mono : ∀ (g : ℝ → ℝ),\n      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by\n    intro g hg\n    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)\n    · intro y hy\n      exact (hg y hy).continuousAt.continuousWithinAt\n    · intro y hy\n      exact (hg y (interior_subset hy)).hasDerivWithinAt\n    · intro y hy\n      exact le_refl 0\n  have hd : ∀ y ∈ Set.Icc u v,\n      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by\n    intro y hy\n    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))\n    simpa only [sub_self] using (hf y hy).sub hh\n  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd\n  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by\n    intro y hy\n    simpa only [neg_zero] using (hd y hy).neg)\n  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv\n  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv\n  have hzero : heatingTime capacity W k A u u = 0 := by\n    simp only [heatingTime, sub_self, mul_zero]\n  linarith\n\n'''\ns=s.replace(marker, addition+marker)\n# Remove redundant tactics where compiler has shown they are not needed.\ns=s.replace('  field_simp\\\\n  <;> ring','  field_simp\\\\n  ring')\ns=s.replace('  field_simp [hk, hv]\\\\n  <;> ring','  field_simp [hk, hv]')\ns=s.replace('    field_simp [hc, hk, hx, hz]\\\\n    <;> ring','    field_simp [hc, hk, hx, hz]\\\\n    ring')\nopen(p,'w').write(s)\nPY\nsource lean-env.sh\n/opt/lean/bin/lean Model.lean > diagnostics/cycle2-compile-3.log 2>&1\""
}
web_search input
{
  "query": "site.ahtt.mit.edu Newton law cooling textbook ...",
  "action": {
    "type": "search",
    "queries": [
      "site.ahtt.mit.edu Newton law cooling textbook",
      "site.openstax.org \"Newton’s law of cooling\""
    ]
  }
}
shell output · exit 1 · failed
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "bpb-us-e1.wpmucdn.com",
      "ref_id": "turn3search12",
      "snippet": "In 1701, Isaac Newton considered the convective process and suggested that the cooling would be such that ... Heat flows out of the body, so",
      "title": "A Heat Transfer Textbook, 6th edition",
      "url": "https://bpb-us-e1.wpmucdn.com/sites.mit.edu/dist/6/1810/files/2024/04/AHTTv600.pdf"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn3search0",
      "snippet": "This translation leads to Newton’s Law of Cooling, the scientific formula for temperature as a function of time as an object’s temperature is equalized with",
      "title": "6.7 Exponential and Logarithmic Models - College Algebra | OpenStax",
      "url": "https://openstax.org/books/college-algebra/pages/6-7-exponential-and-logarithmic-models"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn3search1",
      "snippet": "Newton’s law of cooling states that the rate of change of an object’s temperature is proportional to the difference between its own temperature and the",
      "title": "4.3 Separable Equations - Calculus Volume 2 | OpenStax",
      "url": "https://openstax.org/books/calculus-volume-2/pages/4-3-separable-equations"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn3search2",
      "snippet": "* 6.8.3 Use the exponential decay model in applications, including radioactive decay and Newton’s law of cooling. ... Equation 6.27 involves derivatives and is called",
      "title": "6.8 Exponential Growth and Decay - Calculus Volume 1 | OpenStax",
      "url": "https://openstax.org/books/calculus-volume-1/pages/6-8-exponential-growth-and-decay"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn3search3",
      "snippet": "This translation leads to Newton’s Law of Cooling, the scientific formula for temperature as a function of time as an object’s temperature is equalized with",
      "title": "6.7 Exponential and Logarithmic Models - Algebra and Trigonometry 2e | OpenStax",
      "url": "https://openstax.org/books/algebra-and-trigonometry-2e/pages/6-7-exponential-and-logarithmic-models"
    },
    {
      "type": "text_result",
      "domain": "assets.openstax.org",
      "ref_id": "turn3search13",
      "snippet": "Newton’s law of cooling says that an object cools at a rate proportional to the difference between the temperature of the object and the temperature",
      "title": "Calculus Volume 1",
      "url": "https://assets.openstax.org/oscms-prodcms/media/documents/CalculusVolume1-OP.pdf"
    },
    {
      "type": "text_result",
      "domain": "sathee.iitk.ac.in",
      "ref_id": "turn3search4",
      "snippet": "### 10.10 NEWTON’S LAW OF COOLING [219-221]# ... According to Newton’s law of cooling, the rate of loss of heat, $-\\mathrm{d} Q / \\mathrm{d} t$",
      "title": "SATHEE: Chapter 10 Thermal Properties of Matter",
      "url": "https://sathee.iitk.ac.in/sathee-neet/ncert-books/neet-ncert-books/neet-nb-phy-11/phy-11-chapter-10-thermal-properties-of-matter/"
    },
    {
      "type": "text_result",
      "domain": "ocw.mit.edu",
      "ref_id": "turn3search14",
      "snippet": "Newton’s law of cooling states that: the rate of change of the temperature of an object is proportional to the difference between its own temperature",
      "title": "Introduction to Electrical Engineering and Computer Science I",
      "url": "https://ocw.mit.edu/courses/6-01sc-introduction-to-electrical-engineering-and-computer-science-i-spring-2011/b2d8cb0bb07414a21f5ec444fd00d608_MIT6_01SCS11_textbook.pdf"
    },
    {
      "type": "text_result",
      "domain": "studylib.net",
      "ref_id": "turn3search5",
      "snippet": "Cool gas flows past a warm body, as shown in Fig. ... of carrying heat away by a moving fluid convection. In 1701, Isaac Newton",
      "title": "Heat Transfer Textbook, 5th Edition",
      "url": "https://studylib.net/doc/27251161/ahttv500"
    },
    {
      "type": "text_result",
      "domain": "academicweb.nd.edu",
      "ref_id": "turn3search15",
      "snippet": "In fact Newton’s law of cooling (see Eq. ... Use Newton’s law of cooling along with the first law of thermodynamics and a caloric state",
      "title": "LECTURE NOTES ON",
      "url": "https://academicweb.nd.edu/~powers/ame.20231/notes.pdf"
    },
    {
      "type": "text_result",
      "domain": "edfinitytextbooks.org",
      "ref_id": "turn3search6",
      "snippet": "This translation leads to Newton’s Law of Cooling, the scientific formula for temperature as a function of time as an object’s temperature is equalized with",
      "title": "6.7 Exponential and Logarithmic Models – Algebra and Trigonometry 2e",
      "url": "https://edfinitytextbooks.org/openstax/math/alg-and-trig/chapters/sec-6-7"
    },
    {
      "type": "text_result",
      "domain": "www.indians.k12.pa.us",
      "ref_id": "turn3search16",
      "snippet": "This observation is Newton’s Law of Cooling, although it applies to warming as well, and ... This equation also bears the name Newton’s ... Model",
      "title": "Chapter6\nDifferential Equations\nand Mathematical\nM",
      "url": "https://www.indians.k12.pa.us/cms/lib/PA01001568/Centricity/Domain/893/Calculus%20Textbook%20Chapter%206.pdf"
    },
    {
      "type": "text_result",
      "domain": "www.open.edu",
      "ref_id": "turn3search17",
      "snippet": "Newton’s law of cooling ... Newton’s law of cooling ... To find a particular solution of the differential equation, we need an initial",
      "title": "MST125\nEssential mathematics 2\nDifferential equatio",
      "url": "https://www.open.edu/openlearn/mod/oucontent/olink.php?id=70396&targetdoc=17mst125u8-extract.pdf"
    },
    {
      "type": "text_result",
      "domain": "www.vaia.com",
      "ref_id": "turn3search7",
      "snippet": "Problem 10 Newton's law of cooling in its more general form tells us that the rate at which the temperature between an object and its",
      "title": "Free solutions & answers for Calculus: An Integrated Approach to Functions and Their Rates of Change Chapter 15 - (Page 1) [step by step] | Vaia",
      "url": "https://www.vaia.com/en-us/textbooks/math/calculus-an-integrated-approach-to-functions-and-their-rates-of-change-1-edition/chapter-15/"
    },
    {
      "type": "text_result",
      "domain": "math.libretexts.org",
      "ref_id": "turn3search8",
      "snippet": "Newton’s law of cooling states that the rate of change of an object’s temperature is proportional to the difference between its own temperature and the",
      "title": "8.3: Separable Equations - Mathematics LibreTexts",
      "url": "https://math.libretexts.org/Bookshelves/Calculus/Calculus_%28OpenStax%29/08%3A_Introduction_to_Differential_Equations/8.03%3A_Separable_Equations"
    },
    {
      "type": "text_result",
      "domain": "www.sciencedirect.com",
      "ref_id": "turn3search9",
      "snippet": "This paper will show that so-called “Newton’s law of cooling” that is often used for calculating of heat transfer by convection is actually not a",
      "title": "Newton’s law of cooling and its interpretation",
      "url": "https://www.sciencedirect.com/science/article/pii/S0017931012001846"
    },
    {
      "type": "text_result",
      "domain": "doi.org",
      "ref_id": "turn3search10",
      "snippet": "# The cooling law and the search for a good temperature scale, from Newton to Dalton",
      "title": "The cooling law and the search for a good temperature scale, from Newton to Dalton",
      "url": "https://doi.org/10.1088/0143-0807/32/2/007"
    },
    {
      "type": "text_result",
      "domain": "sethfraden.github.io",
      "ref_id": "turn3search11",
      "snippet": "Heat Convection And Newton's Law Of Cooling¶ ... 1.10, textbook p. 23: when internal conduction is fast compared with surface cooling, the body remains nearly",
      "title": "Module 7, Part I: Thermal Transport Foundations - Phys 39 | Instrumentation and Thermal Physics",
      "url": "https://sethfraden.github.io/Phys39F26-course/labs/theory-bridge-chapter-1/"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn3search18",
      "snippet": "In convective heat transfer, Newton's Law is followed for forced air or pumped fluid cooling, where the properties of the fluid do not vary strongly",
      "title": "Newton's law of cooling",
      "url": "https://en.wikipedia.org/wiki/Newton%27s_law_of_cooling"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn3search19",
      "snippet": "In the case of heat transfer by thermal radiation, Newton's law of cooling holds only for very small temperature differences.",
      "title": "Heat transfer",
      "url": "https://en.wikipedia.org/wiki/Heat_transfer"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn3search20",
      "snippet": "This second system of measurement led Newton to derive his law of convective heat transfer, also known as Newton's law of cooling. ... \"Newton's temperature",
      "title": "Newton scale",
      "url": "https://en.wikipedia.org/wiki/Newton_scale"
    },
    {
      "type": "text_result",
      "domain": "fr.wikipedia.org",
      "ref_id": "turn3search21",
      "snippet": "* [3] History of Newton's cooling law Archived 2015-06-14 at the Wayback Machine ... * A Heat Transfer Textbook, 5/e, free ebook.",
      "title": "Loi de refroidissement de Newton",
      "url": "https://fr.wikipedia.org/wiki/Loi_de_refroidissement_de_Newton"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn3search22",
      "snippet": "Undergraduate textbook ... An Introduction to Mechanics, commonly referred to as Kleppner and Kolenkow, is an undergraduate-level textbook on classical mechanics written by physicists Daniel",
      "title": "An Introduction to Mechanics",
      "url": "https://en.wikipedia.org/wiki/An_Introduction_to_Mechanics"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn3search23",
      "snippet": "Newton also formulated an empirical law of cooling, which was the first heat transfer formulation and serves as the formal basis of convective heat transfer,",
      "title": "Isaac Newton",
      "url": "https://en.wikipedia.org/wiki/Isaac_Newton"
    },
    {
      "type": "text_result",
      "domain": "arxiv.org",
      "ref_id": "turn3academia24",
      "snippet": "The microscopic basis of Newton's law of cooling and its modification when the difference in temperature between the system and the surroundings is very large",
      "title": "On the microscopic basis of Newton's law of cooling and beyond",
      "url": "https://arxiv.org/abs/0801.4247"
    },
    {
      "type": "text_result",
      "domain": "arxiv.org",
      "ref_id": "turn3academia25",
      "snippet": "We study a thermal engine model for which Newton's cooling law is obeyed during heat transfer processes.",
      "title": "Efficiency and Its Bounds for Thermal Engines at Maximum Power using a Newton's Law of Cooling",
      "url": "https://arxiv.org/abs/1211.6789"
    },
    {
      "type": "text_result",
      "domain": "arxiv.org",
      "ref_id": "turn3academia26",
      "snippet": "Title: From Kepler's laws to Newton's law: a didactical proof",
      "title": "From Kepler's laws to Newton's law: a didactical proof",
      "url": "https://arxiv.org/abs/2003.13405"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat diagnostics/cycle2-compile-3.log'"
}
shell output · exit 0
Model.lean:95:4: error: Type mismatch: After simplification, term
  HasDerivAt.sub (hf y hy) hh
 has type
  @HasDerivAt ℝ DenselyNormedField.toNontriviallyNormedField ℝ Real.normedAddCommGroup.toAddCommGroup
    NormedField.toNormedSpace.toModule PseudoMetricSpace.toUniformSpace.toTopologicalSpace ⋯
    (f - fun y => heatingTime capacity W k A u y) 0 y
but is expected to have type
  @HasDerivAt ℝ DenselyNormedField.toNontriviallyNormedField ℝ Real.instAddCommGroup Semiring.toModule
    PseudoMetricSpace.toUniformSpace.toTopologicalSpace ⋯ (fun w => f w - heatingTime capacity W k A u w) 0 y
Model.lean:99:4: error: Type mismatch: After simplification, term
  HasDerivAt.neg (hd y hy)
 has type
  @HasDerivAt ℝ DenselyNormedField.toNontriviallyNormedField ℝ Real.normedAddCommGroup.toAddCommGroup
    NormedField.toNormedSpace.toModule PseudoMetricSpace.toUniformSpace.toTopologicalSpace ⋯
    (-fun w => f w - heatingTime capacity W k A u w) 0 y
but is expected to have type
  @HasDerivAt ℝ DenselyNormedField.toNontriviallyNormedField ℝ Real.instAddCommGroup Semiring.toModule
    PseudoMetricSpace.toUniformSpace.toTopologicalSpace ⋯ (fun w => -(f w - heatingTime capacity W k A u w)) 0 y
web_search input
{
  "query": "https://openstax.org/books/calculus-volume-2/pages/4-3-separable-equations",
  "action": {
    "type": "open_page",
    "url": "https://openstax.org/books/calculus-volume-2/pages/4-3-separable-equations"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn4view0",
      "snippet": "Total lines: 524",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/jjf-nMkTy3yfM0emStUxaa2OrqUC2QI8tdn8MmA3UC8MFlET9oEUvvJPFu6HBopz2oG-dAUpvirVd7WXTzFPc0g5_O65Acnn51Zp9I6ok4wupCyRhlFMvlpwkMjh8sXwHrA1zN3aRtTCwWmwG02Hfw",
      "title": "4.3 Separable Equations - Calculus Volume 2 | OpenStax",
      "url": "https://openstax.org/books/calculus-volume-2/pages/4-3-separable-equations"
    },
    {
      "type": "text_result",
      "domain": "openstax.org",
      "ref_id": "turn4view1",
      "snippet": "Total lines: 533",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/njW-BuRqEXWSX99Bg936iktjEm7QfUEHUUt0G5ByalgNxzkU0VppRO-DdL4S5wFd7ICcLsfEWRTEU-A4wJJ-4j3SJ5ntTTeKHv-MGILtkwWlMA1TL2Y__FKKOXUs7qzgTiWGAGPKYsdV_jk7c7sYgw",
      "title": "11.4 Colligative Properties - Chemistry 2e | OpenStax",
      "url": "https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='Model.lean';s=open(p).read().replace('    simpa only [sub_self] using (hf y hy).sub hh','    convert (hf y hy).sub hh using 1 <;> simp').replace('    simpa only [neg_zero] using (hd y hy).neg)','    convert (hd y hy).neg using 1 <;> simp)');open(p,'w').write(s)\nPY\nsource lean-env.sh\n/opt/lean/bin/lean Model.lean > diagnostics/cycle2-compile-4.log 2>&1\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'cat diagnostics/cycle2-compile-4.log'"
}
shell output · exit 0
Model.lean:95:37: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:99:34: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:95:37: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
Model.lean:99:34: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
assistant
The Lean proof now compiles locally. It derives the power jump from mixing and heat loss, derives the stage heating time from the energy equation, and proves that immediate addition minimizes the modeled total time. The capacity and dissolution assumptions remain unmeasured approximations. I’m documenting those limits before running the required extraction and kernel check.
shell input
{
  "command": "/usr/bin/bash -lc \"cat > report.txt <<'EOF'\nScientific answer and scope\n\nThe information supplied does not determine a universal best addition temperature or a number of seconds. A useful conditional prediction is: add the salt immediately, at the supplied 20 degrees C (elapsed time zero), if it is cool salt with nonnegative dissolution energy cost, and the additive-capacity, constant-heater, linear-loss model below applies. Immediate addition is a global weak minimum in that model; this theorem does not assert a unique optimum or a measured time saving. The parameters are symbolic, not fitted. Neither the observations nor the formal check establish that these assumptions describe this particular pot and salt.\n\nThis revision addresses the human rejection recorded on 2026-11-17: the earlier model left the before/after net powers P,Q independent. That proof was mathematically verified but scientifically rejected. Its files are preserved in history/cycle1/, and its raw checks remain under checks/. The new model replaces independent stage powers with ONE shared temperature-dependent energy-transfer law, derives the power change on adding salt, and uses the resulting relationship throughout the heating trajectories to optimize timing. This is a change of model, not a new interpretation of the old theorem. No operator response has been requested or invented; incorporated_inputs is empty. No experiment was performed.\n\nSupplied information versus additional choices\n\nSupplied: 1 litre of water at 20 degrees C, in a pot on a stove; salt will be added. Salt amount, identity beyond 'salt', salt temperature, pot properties, heater and room conditions have not been specified. There are no heating curves or heat-flow observations. The volume alone does not determine the water-plus-pot heat capacity. It is not converted into an invented exact capacity or mass.\n\nChosen deterministic physical model: treat water and pot as one well-mixed thermal body initially at 20 degrees C. C>0 is their constant combined heat capacity (J/K). Add a fixed quantity of completely soluble salt with initial temperature Ts, the same across schedules. Assume Ts <= 20 degrees C for the reported minimum. Approximate the extra sensible heat capacity by S>=0 and the final solution-plus-pot capacity by C+S. Use a constant dissolution energy cost H>=0 (joules, positive for heat absorbed). These are independent calorimetric approximations. In particular S is an additive effective increment; S>=0 is NOT inferred from the volume or established as an exact property of real brine. Temperature-dependent solution heat capacities and dissolution enthalpies can invalidate these approximations. The sign and constancy of H over the heating range are hypotheses, not conclusions drawn from the word 'salt'. No numerical thermochemical values are imported from literature.\n\nAssume instantaneous mixing and complete dissolution, no pause in heater input, no material loss or evaporation, and no phase changes before the endpoint. The mixture must remain liquid and the salt quantity must be soluble. Compare a fixed final composition and pressure, hence a fixed final solution boiling temperature B, left unknown. Boiling means first arrival of the mixed salted solution at this equilibrium temperature, not transient bubbles. Feasible addition temperatures are below the pure-water boiling point (unless salting at its onset). The mathematical comparison is proved on the larger interval [20,B], so it holds on this physical subset whenever the model applies; it does not authorize prolonged unsalted boiling or ignore evaporation occurring there.\n\nThe heater supplies constant thermal power W to the body. Heat loss to a room at fixed temperature A is k(T-A), with k>0 in W/K. The same W and k apply before and after salting, with no direct concentration dependence at a common temperature. Thus the physical law is\n  capacity * dT/dt = N(T),     N(T) = W - k(T-A).\nThis represents a constant-input stove and an effective Newton cooling loss. A linear loss is a tractable approximation motivated by convective/conductive heat transfer, not an exact law for an evaporating pot over an arbitrary temperature range. Radiation, changes of surface area, salt suppression of evaporation, heater controls, and concentration-dependent transfer are omitted. These may matter in an actual apparatus. W is heater-to-system input, not electrical/gas rating. The formal result needs the combined reachability condition N(B)>0; it does not fit W,k,A separately. With k>0 this implies positive net heating at every modeled temperature below B.\n\nObservation/inference model: there are no stochastic observations or empirical parameter estimates, so no likelihood or prior is introduced. A deterministic first-law model gives conditional predictions. The initial condition sets the integration origin; it does not estimate C,S,H,Ts,W,k,A or B. Measurements of heating curves, salt quantity and temperature, mixing cooling, and final boiling temperature would be needed to calibrate and test this family. In particular a before/after heating-rate measurement must account for the changed heat capacity to infer net power. Until such evidence exists, the conclusion is conditional rather than a universal kitchen timing rule.\n\nPhysical inference and its Lean translation\n\nAll five public definitions are scientifically necessary, with temperatures in degrees C, elapsed times in seconds, capacities in J/K and powers in watts:\n  initialTemperature = 20.\n  netPower W k A T = N(T) = W-k(T-A).\n  mixedTemperature C S H Ts x = z(x) = (C*x + S*Ts-H)/(C+S).\n  heatingTime capacity W k A u v = capacity/k * [ln N(u)-ln N(v)].\n  boilingTime C S H Ts B W k A x = t(x)\n      = heatingTime C W k A 20 x\n        + heatingTime (C+S) W k A z(x) B.\nThe logarithm difference is equivalently ln[N(u)/N(v)], a dimensionless ratio of powers; the formalization uses fixed SI numerical values. No logarithm of nonpositive power is used in the applicable domain.\n\nThe mixing formula follows from sensible energy and dissolution conservation:\n  (C+S)*z = C*x + S*Ts-H.\nThis equation includes heating the added salt and paying dissolution energy. The lemma mixing_balance verifies it. Applying the SHARED heat-loss law at the two temperatures yields the derived relationship (power_change):\n  N(z(x))-N(x) = k * [S*(x-Ts)+H]/(C+S).\nFor Ts<=20<=x, S,H>=0 the right side is nonnegative. Thus net heating power immediately after mixing is at least its value immediately before mixing. This comes from a reduced liquid temperature and hence reduced losses; the model does not increase the heater input or heat-transfer coefficient. At a common temperature the power is the same before and after salt addition. Increased net power does not by itself imply an increased temperature rate, because heat capacity has also changed. The proof compares the full times.\n\nTo derive stage times, invert the first law on a strictly heating stage:\n  df/dT = capacity/N(T),    f(u)=0.\nThe lemma heating_time_derivative checks that heatingTime has exactly this derivative. The lemma stage_time_from_energy proves that ANY differentiable inverse elapsed-time curve satisfying that energy law on [u,v] and the zero initial condition has endpoint f(v)=heatingTime(...,u,v). It proves uniqueness by applying the mean-value monotonicity theorem to the difference and its negative. Thus the logarithmic time is derived from the energy equation rather than fitted or assumed as a timing optimum. Endpoint derivatives in that lemma are understood using smooth local extensions, possible when net power is strictly positive. For the two stages the capacities are C and C+S and the endpoints are (20,x) and (z(x),B). Their times add because mixing is instantaneous. This justifies boilingTime as the first-arrival time in this deterministic model.\n\nDifferentiating the full time, boiling_time_derivative proves\n  dt/dx = C/N(x) - C/N(z(x)).\nThe power_order lemma derives 0 < N(x) <= N(z(x)) from the common heater/loss law and mixing balance under the stated hypotheses. It follows that dt/dx >= 0 throughout [20,B]. The final proof uses the mean-value monotonicity theorem to conclude t(20)<=t(x) for every admissible later addition. This accounts for subsequent temperature-dependent power; it does not replace it by an independent constant Q. Also heatingTime(C,...,20,20)=0, so the minimizing temperature corresponds to adding at elapsed time zero.\n\nExact final conclusion and compact review boundary\n\nThe sole submitted conclusion is the top-level theorem addition_timing_answer. For every C,S,H,Ts,B,W,k,A,x satisfying\n  C>0; S>=0; H>=0; Ts<=initialTemperature;\n  k>0; netPower W k A B>0; initialTemperature<=x<=B,\nit proves the conjunction:\n  N(z(x))-N(x) = k*[S*(x-Ts)+H]/(C+S);\n  N(x)<=N(z(x));\n  boilingTime(...,20)<=boilingTime(...,x);\n  heatingTime(C,...,20,20)=0.\nThe first identity exposes the requested derived change in net heating power. The last two statements answer the temperature/time choice: now at 20 degrees C is no slower than a later feasible addition, within this model. Weak inequality is deliberate; no strictness or magnitude is inferred.\n\nReview supplied facts: volume and initial temperature, heating, unspecified salt/apparatus.\nReview independent choices: fixed soluble salt amount/final composition/pressure and B; uniform body initially equilibrated with pot; constant additive C,S and constant H with the displayed signs; fixed cool Ts; instantaneous mixing with no phases or evaporation; constant heater and shared linear loss with positive net power at B.\nReview necessary definitions: exactly the five definitions translated above. All mixing balance identities, power changes, positivity in the heating range, stage-time integration, and time monotonicity are proved, not added as axioms. No sorry or additional axioms are used. Standard logical axioms of Lean/Mathlib are not physical premises.\nReview limits: mathematical implication does not prove the physical model or signs for an unspecified salt or apparatus. If these assumptions fail, this theorem supplies no optimum. In the distinct lossless constant-input idealization the total energy divided by input power is independent of timing (the conditional tie established in cycle 1); the current definition uses k>0 and does not evaluate its logarithmic formula at k=0. Neither model yields a supported numerical boiling time from the supplied information. No human acceptance is claimed.\n\nLiterature consulted this cycle (general background, not system measurements)\n\nOpenStax, Calculus Volume 2, 4.3 Separable Equations:\nhttps://openstax.org/books/calculus-volume-2/pages/4-3-separable-equations\nSupports the general Newton cooling and separation-of-variables model family. The fixed input, unchanged effective loss coefficient and applicability to this pot remain explicit choices.\n\nOpenStax, University Physics Volume 2, 1.6 Mechanisms of Heat Transfer:\nhttps://openstax.org/books/university-physics-volume-2/pages/1-6-mechanisms-of-heat-transfer\nSupports the distinction between heat-transfer mechanisms and their temperature dependence. It does not establish this stove's W or k.\n\nOpenStax, Chemistry 2e, 11.1 The Dissolution Process:\nhttps://openstax.org/books/chemistry-2e/pages/11-1-the-dissolution-process\nSupports including absorbed or released energy in dissolution; the nonnegative constant H used here is conditional, not a general claim for all salts.\n\nOpenStax, Chemistry 2e, 11.4 Colligative Properties:\nhttps://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties\nSupports treating the salted boiling temperature as composition-dependent rather than assuming it is 100 degrees C. B is not computed without composition and pressure.\n\nCheck lineage\n\nCycle 1: first check failed on unavailable umbrella tactic import, second on exact extraction identity, third proved the old independent-power theorem, which was then rejected by the human. Those raw traces are retained. This cycle's local compilation diagnostics are diagnostics/cycle2-compile-1.log through cycle2-compile-4.log. They record corrections of noncomputable definitions, function equalities and calculus typeclass inference; none of those fixes changed the physical model. The current candidate must pass the actual harness check, independent statement extraction and kernel recheck before any formal verification claim. Human scientific review remains separate.\nEOF\npython - <<'PY'\nimport json\nm={\n 'proof_file':'Model.lean', 'narrative_file':'report.txt',\n 'conclusions':{'answer':'addition_timing_answer'},\n 'user_facts':['1 litre of water initially at 20 degrees Celsius is being heated in a pot on a stove.','Salt will be added; salt quantity, pot, heater and room conditions are unspecified.'],\n 'model_choices':[\n 'Deterministic lumped energy balance, with pot initially at the supplied water temperature; C>0 is constant water-plus-pot heat capacity, and the constant additive salt contribution S>=0 gives final capacity C+S.',\n 'Fixed soluble salt quantity, fixed salt temperature Ts<=20 C, constant dissolution heat cost H>=0, fixed final composition and pressure, hence fixed but unestimated solution boiling temperature B.',\n 'Instantaneous complete mixing and dissolution, no evaporation, phase change, material loss or heater pause; only liquid, soluble, physically feasible pre-boiling addition schedules apply.',\n 'Constant heater-to-body input W and room temperature A, shared before/after Newton heat-loss law k*(T-A), k>0, so netPower(T)=W-k*(T-A); no independent salinity dependence of heat transfer. Require netPower(B)>0 for reachability.',\n 'Heating stages obey the deterministic first law dt/dT=capacity/netPower(T); the logarithmic elapsed-time formula is derived and its uniqueness proved. No empirical parameter estimates, likelihood or prior are claimed.'\n ],\n 'sources':[\n 'https://openstax.org/books/calculus-volume-2/pages/4-3-separable-equations',\n 'https://openstax.org/books/university-physics-volume-2/pages/1-6-mechanisms-of-heat-transfer',\n 'https://openstax.org/books/chemistry-2e/pages/11-1-the-dissolution-process',\n 'https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties'\n ],\n 'incorporated_inputs':[],\n 'proof_scope':'Derives the mixing balance and net-power jump from a shared constant-input/linear-loss physical model; derives the stage-time formula from the inverse differential energy law, differentiates the complete boiling time and proves a global weak minimum for immediate addition at 20 C (zero waiting) under cool-salt, nonnegative additive capacity and dissolution cost assumptions. Does not estimate physical parameters, establish those approximations for the actual pot/salt, assert a unique universal optimum or numerical boiling time, or claim human approval.'\n}\nopen('candidate.json','w').write(json.dumps(m,indent=2)+'\\\\n')\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json > diagnostics/cycle2-check-1.txt 2>&1\""
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat diagnostics/cycle2-check-1.txt; ls -td checks/* | head -2'"
}
shell output · exit 0
checks/19e916da3a2f417381acb479d8151af9
checks/cd3bf32329e547d19d474c1bd79431b9
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la checks/19e916da3a2f417381acb479d8151af9; cat checks/19e916da3a2f417381acb479d8151af9/lean.log'"
}
shell output · exit 0
total 72
drwxr-xr-x 2 1001 1001  4096 Nov 17 14:22 .
drwxr-xr-x 6 1001 1001  4096 Nov 17 14:22 ..
-rw-r--r-- 1 1001 1001 12280 Nov 17 14:22 Checked.lean
-rw-r--r-- 1 1001 1001 15382 Nov 17 14:22 extracted.probe.lean
-rw-r--r-- 1 1001 1001  1000 Nov 17 14:22 lean.log
-rw------- 1 1001 1001  2412 Nov 17 14:22 submitted-candidate.json
-rw-r--r-- 1 1001 1001 12432 Nov 17 14:22 submitted-report.txt
-rw-r--r-- 1 1001 1001  9099 Nov 17 14:22 submitted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean:95:37: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean:99:34: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean:95:37: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean:99:34: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
'addition_timing_answer' depends on axioms: [propext, Classical.choice, Quot.sound]
VAS_LISTED

leanchecker exit 0

shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'cat diagnostics/cycle2-check-1.txt; cat checks/19e916da3a2f417381acb479d8151af9/verdict.json'"
}
shell output · exit 0
{
 "file": "/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean",
 "conclusions": [
  "addition_timing_answer"
 ],
 "lean_exit": 0,
 "ok": true,
 "compiles_alone": true,
 "faithful": {
  "addition_timing_answer": true
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
  "heatingTime",
  "boilingTime"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "addition_timing_answer": {
   "original_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16",
   "extracted_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16"
  }
 },
 "dependency_faithful": {
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "netPower": true,
  "mixedTemperature": true,
  "boilingTime": true,
  "heatingTime": true
 },
 "dependency_identities": {
  "initialTemperature": {
   "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
   "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
  },
  "initialTemperature._proof_1": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "netPower": {
   "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
   "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
  },
  "mixedTemperature": {
   "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
   "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
  },
  "boilingTime": {
   "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
   "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
  },
  "heatingTime": {
   "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
   "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "addition_timing_answer": "\u2200 (C S H Ts B W k A x : \u211d), 0 < C \u2192 0 \u2264 S \u2192 0 \u2264 H \u2192 Ts \u2264 initialTemperature \u2192 0 < k \u2192 0 < netPower W k A B \u2192 initialTemperature \u2264 x \u2192 x \u2264 B \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 netPower W k A x \u2264 netPower W k A (mixedTemperature C S H Ts x) \u2227 boilingTime C S H Ts B W k A initialTemperature \u2264 boilingTime C S H Ts B W k A x \u2227 heatingTime C W k A initialTemperature initialTemperature = 0"
 },
 "extracted_file": "/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean",
 "errors": []
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T14:22:00.296935+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16",
        "extracted_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "netPower": true,
      "mixedTemperature": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B W k A x : \u211d), 0 < C \u2192 0 \u2264 S \u2192 0 \u2264 H \u2192 Ts \u2264 initialTemperature \u2192 0 < k \u2192 0 < netPower W k A B \u2192 initialTemperature \u2264 x \u2192 x \u2264 B \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 netPower W k A x \u2264 netPower W k A (mixedTemperature C S H Ts x) \u2227 boilingTime C S H Ts B W k A initialTemperature \u2264 boilingTime C S H Ts B W k A x \u2227 heatingTime C W k A initialTemperature initialTemperature = 0"
    },
    "extracted_file": "/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T14:22:00.296935+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16",
        "extracted_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "netPower": true,
      "mixedTemperature": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B W k A x : \u211d), 0 < C \u2192 0 \u2264 S \u2192 0 \u2264 H \u2192 Ts \u2264 initialTemperature \u2192 0 < k \u2192 0 < netPower W k A B \u2192 initialTemperature \u2264 x \u2192 x \u2264 B \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 netPower W k A x \u2264 netPower W k A (mixedTemperature C S H Ts x) \u2227 boilingTime C S H Ts B W k A initialTemperature \u2264 boilingTime C S H Ts B W k A x \u2227 heatingTime C W k A initialTemperature initialTemperature = 0"
    },
    "extracted_file": "/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
assistant
The revised model proves that **adding salt immediately at 20 °C minimizes boiling time**, conditional on cool salt, nonnegative dissolution energy, additive heat capacities, constant heater input and linear heat loss. Mixing reduces temperature and heat loss; the proof derives that power change and compares total heating times.

The unspecified conditions prevent a universal numerical recommendation.

[Candidate](/work/candidate.json), [proof](/work/Model.lean), and [report](/work/report.txt) are ready for human review. The actual check, independent extraction and kernel recheck passed; physical assumptions remain unverified.

Produced code

attempt-002/Model.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
attempt-002/extracted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

def initialTemperature : ℝ := 20

def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B


/-! Conclusions (statements of the proved theorems). -/
def conclusion_addition_timing_answer : Prop := ∀ (C S H Ts B W k A x : ℝ), 0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature → 0 < k → 0 < netPower W k A B → initialTemperature ≤ x → x ≤ B → (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S)) ∧ (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧ (boilingTime C S H Ts B W k A initialTemperature ≤ boilingTime C S H Ts B W k A x) ∧ (heatingTime C W k A initialTemperature initialTemperature = 0)
checks/19e916da3a2f417381acb479d8151af9/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring

Round 3

Messages

assistant
I’ll review the earlier model and check feedback, then revise the heat-capacity and dissolution-energy treatment and re-derive the timing result within the feasible liquid-temperature range.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work'"
}
shell output · exit 0
total 72
drwxrwxr-x 5 1001 1001  4096 Nov 17 15:42 .
drwxr-xr-x 1 root root  4096 Nov 17 15:42 ..
-rw-r--r-- 1 1001 1001  9099 Nov 17 14:19 Model.lean
-rw-r--r-- 1 1001 1001  2412 Nov 17 14:21 candidate.json
drwxr-xr-x 6 1001 1001  4096 Nov 17 14:22 checks
drwxr-xr-x 2 1001 1001  4096 Nov 17 14:21 diagnostics
drwxr-xr-x 3 1001 1001  4096 Nov 17 14:15 history
-rw------- 1 1001 1001  1203 Nov 17 15:42 human-feedback.json
-rw------- 1 1001 1001  8523 Nov 17 14:22 last-review-packet.json
-rw-r--r-- 1 1001 1001   456 Nov 17 14:15 lean-env.sh
-rw-r--r-- 1 1001 1001 12432 Nov 17 14:21 report.txt
shell input
{
  "command": "/usr/bin/bash -lc 'cat Model.lean candidate.json report.txt human-feedback.json lean-env.sh'"
}
shell output · exit 0
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "addition_timing_answer"
  },
  "user_facts": [
    "1 litre of water initially at 20 degrees Celsius is being heated in a pot on a stove.",
    "Salt will be added; salt quantity, pot, heater and room conditions are unspecified."
  ],
  "model_choices": [
    "Deterministic lumped energy balance, with pot initially at the supplied water temperature; C>0 is constant water-plus-pot heat capacity, and the constant additive salt contribution S>=0 gives final capacity C+S.",
    "Fixed soluble salt quantity, fixed salt temperature Ts<=20 C, constant dissolution heat cost H>=0, fixed final composition and pressure, hence fixed but unestimated solution boiling temperature B.",
    "Instantaneous complete mixing and dissolution, no evaporation, phase change, material loss or heater pause; only liquid, soluble, physically feasible pre-boiling addition schedules apply.",
    "Constant heater-to-body input W and room temperature A, shared before/after Newton heat-loss law k*(T-A), k>0, so netPower(T)=W-k*(T-A); no independent salinity dependence of heat transfer. Require netPower(B)>0 for reachability.",
    "Heating stages obey the deterministic first law dt/dT=capacity/netPower(T); the logarithmic elapsed-time formula is derived and its uniqueness proved. No empirical parameter estimates, likelihood or prior are claimed."
  ],
  "sources": [
    "https://openstax.org/books/calculus-volume-2/pages/4-3-separable-equations",
    "https://openstax.org/books/university-physics-volume-2/pages/1-6-mechanisms-of-heat-transfer",
    "https://openstax.org/books/chemistry-2e/pages/11-1-the-dissolution-process",
    "https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties"
  ],
  "incorporated_inputs": [],
  "proof_scope": "Derives the mixing balance and net-power jump from a shared constant-input/linear-loss physical model; derives the stage-time formula from the inverse differential energy law, differentiates the complete boiling time and proves a global weak minimum for immediate addition at 20 C (zero waiting) under cool-salt, nonnegative additive capacity and dissolution cost assumptions. Does not estimate physical parameters, establish those approximations for the actual pot/salt, assert a unique universal optimum or numerical boiling time, or claim human approval."
}
Scientific answer and scope

The information supplied does not determine a universal best addition temperature or a number of seconds. A useful conditional prediction is: add the salt immediately, at the supplied 20 degrees C (elapsed time zero), if it is cool salt with nonnegative dissolution energy cost, and the additive-capacity, constant-heater, linear-loss model below applies. Immediate addition is a global weak minimum in that model; this theorem does not assert a unique optimum or a measured time saving. The parameters are symbolic, not fitted. Neither the observations nor the formal check establish that these assumptions describe this particular pot and salt.

This revision addresses the human rejection recorded on 2026-11-17: the earlier model left the before/after net powers P,Q independent. That proof was mathematically verified but scientifically rejected. Its files are preserved in history/cycle1/, and its raw checks remain under checks/. The new model replaces independent stage powers with ONE shared temperature-dependent energy-transfer law, derives the power change on adding salt, and uses the resulting relationship throughout the heating trajectories to optimize timing. This is a change of model, not a new interpretation of the old theorem. No operator response has been requested or invented; incorporated_inputs is empty. No experiment was performed.

Supplied information versus additional choices

Supplied: 1 litre of water at 20 degrees C, in a pot on a stove; salt will be added. Salt amount, identity beyond 'salt', salt temperature, pot properties, heater and room conditions have not been specified. There are no heating curves or heat-flow observations. The volume alone does not determine the water-plus-pot heat capacity. It is not converted into an invented exact capacity or mass.

Chosen deterministic physical model: treat water and pot as one well-mixed thermal body initially at 20 degrees C. C>0 is their constant combined heat capacity (J/K). Add a fixed quantity of completely soluble salt with initial temperature Ts, the same across schedules. Assume Ts <= 20 degrees C for the reported minimum. Approximate the extra sensible heat capacity by S>=0 and the final solution-plus-pot capacity by C+S. Use a constant dissolution energy cost H>=0 (joules, positive for heat absorbed). These are independent calorimetric approximations. In particular S is an additive effective increment; S>=0 is NOT inferred from the volume or established as an exact property of real brine. Temperature-dependent solution heat capacities and dissolution enthalpies can invalidate these approximations. The sign and constancy of H over the heating range are hypotheses, not conclusions drawn from the word 'salt'. No numerical thermochemical values are imported from literature.

Assume instantaneous mixing and complete dissolution, no pause in heater input, no material loss or evaporation, and no phase changes before the endpoint. The mixture must remain liquid and the salt quantity must be soluble. Compare a fixed final composition and pressure, hence a fixed final solution boiling temperature B, left unknown. Boiling means first arrival of the mixed salted solution at this equilibrium temperature, not transient bubbles. Feasible addition temperatures are below the pure-water boiling point (unless salting at its onset). The mathematical comparison is proved on the larger interval [20,B], so it holds on this physical subset whenever the model applies; it does not authorize prolonged unsalted boiling or ignore evaporation occurring there.

The heater supplies constant thermal power W to the body. Heat loss to a room at fixed temperature A is k(T-A), with k>0 in W/K. The same W and k apply before and after salting, with no direct concentration dependence at a common temperature. Thus the physical law is
  capacity * dT/dt = N(T),     N(T) = W - k(T-A).
This represents a constant-input stove and an effective Newton cooling loss. A linear loss is a tractable approximation motivated by convective/conductive heat transfer, not an exact law for an evaporating pot over an arbitrary temperature range. Radiation, changes of surface area, salt suppression of evaporation, heater controls, and concentration-dependent transfer are omitted. These may matter in an actual apparatus. W is heater-to-system input, not electrical/gas rating. The formal result needs the combined reachability condition N(B)>0; it does not fit W,k,A separately. With k>0 this implies positive net heating at every modeled temperature below B.

Observation/inference model: there are no stochastic observations or empirical parameter estimates, so no likelihood or prior is introduced. A deterministic first-law model gives conditional predictions. The initial condition sets the integration origin; it does not estimate C,S,H,Ts,W,k,A or B. Measurements of heating curves, salt quantity and temperature, mixing cooling, and final boiling temperature would be needed to calibrate and test this family. In particular a before/after heating-rate measurement must account for the changed heat capacity to infer net power. Until such evidence exists, the conclusion is conditional rather than a universal kitchen timing rule.

Physical inference and its Lean translation

All five public definitions are scientifically necessary, with temperatures in degrees C, elapsed times in seconds, capacities in J/K and powers in watts:
  initialTemperature = 20.
  netPower W k A T = N(T) = W-k(T-A).
  mixedTemperature C S H Ts x = z(x) = (C*x + S*Ts-H)/(C+S).
  heatingTime capacity W k A u v = capacity/k * [ln N(u)-ln N(v)].
  boilingTime C S H Ts B W k A x = t(x)
      = heatingTime C W k A 20 x
        + heatingTime (C+S) W k A z(x) B.
The logarithm difference is equivalently ln[N(u)/N(v)], a dimensionless ratio of powers; the formalization uses fixed SI numerical values. No logarithm of nonpositive power is used in the applicable domain.

The mixing formula follows from sensible energy and dissolution conservation:
  (C+S)*z = C*x + S*Ts-H.
This equation includes heating the added salt and paying dissolution energy. The lemma mixing_balance verifies it. Applying the SHARED heat-loss law at the two temperatures yields the derived relationship (power_change):
  N(z(x))-N(x) = k * [S*(x-Ts)+H]/(C+S).
For Ts<=20<=x, S,H>=0 the right side is nonnegative. Thus net heating power immediately after mixing is at least its value immediately before mixing. This comes from a reduced liquid temperature and hence reduced losses; the model does not increase the heater input or heat-transfer coefficient. At a common temperature the power is the same before and after salt addition. Increased net power does not by itself imply an increased temperature rate, because heat capacity has also changed. The proof compares the full times.

To derive stage times, invert the first law on a strictly heating stage:
  df/dT = capacity/N(T),    f(u)=0.
The lemma heating_time_derivative checks that heatingTime has exactly this derivative. The lemma stage_time_from_energy proves that ANY differentiable inverse elapsed-time curve satisfying that energy law on [u,v] and the zero initial condition has endpoint f(v)=heatingTime(...,u,v). It proves uniqueness by applying the mean-value monotonicity theorem to the difference and its negative. Thus the logarithmic time is derived from the energy equation rather than fitted or assumed as a timing optimum. Endpoint derivatives in that lemma are understood using smooth local extensions, possible when net power is strictly positive. For the two stages the capacities are C and C+S and the endpoints are (20,x) and (z(x),B). Their times add because mixing is instantaneous. This justifies boilingTime as the first-arrival time in this deterministic model.

Differentiating the full time, boiling_time_derivative proves
  dt/dx = C/N(x) - C/N(z(x)).
The power_order lemma derives 0 < N(x) <= N(z(x)) from the common heater/loss law and mixing balance under the stated hypotheses. It follows that dt/dx >= 0 throughout [20,B]. The final proof uses the mean-value monotonicity theorem to conclude t(20)<=t(x) for every admissible later addition. This accounts for subsequent temperature-dependent power; it does not replace it by an independent constant Q. Also heatingTime(C,...,20,20)=0, so the minimizing temperature corresponds to adding at elapsed time zero.

Exact final conclusion and compact review boundary

The sole submitted conclusion is the top-level theorem addition_timing_answer. For every C,S,H,Ts,B,W,k,A,x satisfying
  C>0; S>=0; H>=0; Ts<=initialTemperature;
  k>0; netPower W k A B>0; initialTemperature<=x<=B,
it proves the conjunction:
  N(z(x))-N(x) = k*[S*(x-Ts)+H]/(C+S);
  N(x)<=N(z(x));
  boilingTime(...,20)<=boilingTime(...,x);
  heatingTime(C,...,20,20)=0.
The first identity exposes the requested derived change in net heating power. The last two statements answer the temperature/time choice: now at 20 degrees C is no slower than a later feasible addition, within this model. Weak inequality is deliberate; no strictness or magnitude is inferred.

Review supplied facts: volume and initial temperature, heating, unspecified salt/apparatus.
Review independent choices: fixed soluble salt amount/final composition/pressure and B; uniform body initially equilibrated with pot; constant additive C,S and constant H with the displayed signs; fixed cool Ts; instantaneous mixing with no phases or evaporation; constant heater and shared linear loss with positive net power at B.
Review necessary definitions: exactly the five definitions translated above. All mixing balance identities, power changes, positivity in the heating range, stage-time integration, and time monotonicity are proved, not added as axioms. No sorry or additional axioms are used. Standard logical axioms of Lean/Mathlib are not physical premises.
Review limits: mathematical implication does not prove the physical model or signs for an unspecified salt or apparatus. If these assumptions fail, this theorem supplies no optimum. In the distinct lossless constant-input idealization the total energy divided by input power is independent of timing (the conditional tie established in cycle 1); the current definition uses k>0 and does not evaluate its logarithmic formula at k=0. Neither model yields a supported numerical boiling time from the supplied information. No human acceptance is claimed.

Literature consulted this cycle (general background, not system measurements)

OpenStax, Calculus Volume 2, 4.3 Separable Equations:
https://openstax.org/books/calculus-volume-2/pages/4-3-separable-equations
Supports the general Newton cooling and separation-of-variables model family. The fixed input, unchanged effective loss coefficient and applicability to this pot remain explicit choices.

OpenStax, University Physics Volume 2, 1.6 Mechanisms of Heat Transfer:
https://openstax.org/books/university-physics-volume-2/pages/1-6-mechanisms-of-heat-transfer
Supports the distinction between heat-transfer mechanisms and their temperature dependence. It does not establish this stove's W or k.

OpenStax, Chemistry 2e, 11.1 The Dissolution Process:
https://openstax.org/books/chemistry-2e/pages/11-1-the-dissolution-process
Supports including absorbed or released energy in dissolution; the nonnegative constant H used here is conditional, not a general claim for all salts.

OpenStax, Chemistry 2e, 11.4 Colligative Properties:
https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties
Supports treating the salted boiling temperature as composition-dependent rather than assuming it is 100 degrees C. B is not computed without composition and pressure.

Check lineage

Cycle 1: first check failed on unavailable umbrella tactic import, second on exact extraction identity, third proved the old independent-power theorem, which was then rejected by the human. Those raw traces are retained. This cycle's local compilation diagnostics are diagnostics/cycle2-compile-1.log through cycle2-compile-4.log. They record corrections of noncomputable definitions, function equalities and calculus typeclass inference; none of those fixes changed the physical model. The current candidate must pass the actual harness check, independent statement extraction and kernel recheck before any formal verification claim. Human scientific review remains separate.
{
  "decision": "reject",
  "binding": "229f69c0a4a229a9167170007d0691354e76926a4b40d4503c1c9aae828bf330",
  "reason": "Human TUI requests revision: account for the actual change in total heat capacity on dissolving salt; do not assume S>=0. Determine or justify its sign for an explicitly stated salt/concentration/temperature regime, or derive the appropriate conditional regimes. Preserve positive total capacity C+S>0. Re-derive the net-power change and optimal timing without presuming that mixing always cools the liquid or increases net power when S may be negative. Keep the accepted lumped, constant-input, Newtonian heat-loss approximation. Clarify the reference temperature of the dissolution-energy parameter and use it consistently with the heat-capacity change. Keep the timing domain physically feasible for unsalted water before boiling and the liquid mixture afterward. Within the accepted approximations, operator review found no separate algebraic blocker; these points are consequences and domain requirements of the requested heat-capacity correction. No acceptance of the current recommendation.",
  "time": "2026-11-17T15:42:22.536092+00:00",
  "verification_verdict": "proved"
}
export LEAN_PATH=/harness/.lake/packages/plausible/.lake/build/lib/lean:/harness/.lake/packages/proofwidgets/.lake/build/lib/lean:/harness/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/harness/.lake/packages/mathlib/.lake/build/lib/lean:/harness/.lake/packages/aesop/.lake/build/lib/lean:/harness/.lake/packages/batteries/.lake/build/lib/lean:/harness/.lake/packages/importGraph/.lake/build/lib/lean:/harness/.lake/packages/Qq/.lake/build/lib/lean
shell input
{
  "command": "/usr/bin/bash -lc 'rg --files history checks diagnostics'"
}
shell output · exit 127 · failed
/usr/bin/bash: line 1: rg: command not found
shell input
{
  "command": "/usr/bin/bash -lc 'find history checks diagnostics -type f'"
}
shell output · exit 0
history/cycle1/report.txt
history/cycle1/human-feedback.json
history/cycle1/Model.lean
history/cycle1/candidate.json
checks/cd3bf32329e547d19d474c1bd79431b9/submitted-report.txt
checks/cd3bf32329e547d19d474c1bd79431b9/submitted-candidate.json
checks/cd3bf32329e547d19d474c1bd79431b9/lean.log
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
checks/cd3bf32329e547d19d474c1bd79431b9/extracted.json
checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean
checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean
checks/19e916da3a2f417381acb479d8151af9/submitted-report.txt
checks/19e916da3a2f417381acb479d8151af9/submitted-candidate.json
checks/19e916da3a2f417381acb479d8151af9/lean.log
checks/19e916da3a2f417381acb479d8151af9/submitted.lean
checks/19e916da3a2f417381acb479d8151af9/extracted.json
checks/19e916da3a2f417381acb479d8151af9/extracted.lean
checks/19e916da3a2f417381acb479d8151af9/verdict.json
checks/19e916da3a2f417381acb479d8151af9/Checked.lean
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-report.txt
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-candidate.json
checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-report.txt
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-candidate.json
checks/f49ea96bd5de45babf8f3c699ba15e09/lean.log
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.json
checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean
checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean
diagnostics/extraction-result.txt
diagnostics/probe2.log
diagnostics/extract-trace-1.txt
diagnostics/cycle2-compile-4.log
diagnostics/cycle2-compile-1.log
diagnostics/cycle2-compile-3.log
diagnostics/probe.log
diagnostics/extraction_trace.py
diagnostics/extract-trace-2.txt
diagnostics/extracted.json
diagnostics/cycle2-check-1.txt
diagnostics/extracted.lean
diagnostics/cycle2-compile-2.log
diagnostics/probe2.lean
diagnostics/probe.lean
web_search input
{
  "query": "site.chem.libretexts.org Kirchhoff equation enthalpy reaction heat capacity temperature dissolution ...",
  "action": {
    "type": "search",
    "queries": [
      "site.chem.libretexts.org Kirchhoff equation enthalpy reaction heat capacity temperature dissolution",
      "site.nist.gov aqueous sodium chloride heat capacity solution apparent molar heat capacity"
    ]
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search0",
      "snippet": "Kirchhoff's Law describes the enthalpy of a reaction's variation with temperature changes. ... If the heat capacity is temperature independent over the temperature range, then",
      "title": "Kirchhoff's Law - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Supplemental_Modules_%28Physical_and_Theoretical_Chemistry%29/Thermodynamics/Energies_and_Potentials/Enthalpy/Kirchhoff_Law"
    },
    {
      "type": "text_result",
      "domain": "acris.aalto.fi",
      "ref_id": "turn0search12",
      "snippet": "Journal of Solution Chemistry (2025) 54:286–316 — 307 **Table 10** Recommended value of the relative apparent molar heat capacity (\\(\\Delta C_{\\mathrm{app}}\\), defined in footnote a)",
      "title": "Journal of Solution Chemistry (2025) 54:286–316 — 307",
      "url": "https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search1",
      "snippet": "We wish to find an expression for the reaction enthalpy \\(\\Delta H_{\\mathrm{rxn}}\\left(T^{\\prime \\prime}\\right)\\) for the same values of \\(\\xi_1\\) and \\(\\xi_2\\) at the same pressure",
      "title": "18.4: Molar Reaction Enthalpy - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Chemical_Thermodynamics_%28Supplement_to_Shepherd_et_al.%29/18%3A_Fundamental_13_-_Composition_Changes/18.04%3A_Molar_Reaction_Enthalpy"
    },
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn0search13",
      "snippet": "For aqueous sodium chloride solutions, values of the other constants in Eq. (34) are ... where \\(H^\\circ(T_s)\\) is the molal enthalpy of solid NaCl at",
      "title": "٫R",
      "url": "https://srd.nist.gov/JPCRD/jpcrd239.pdf"
    },
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn0search14",
      "snippet": "In an extensive review of thermal properties of aqueous uni-univalent electrolytes, Parker⁹ critically evaluated the calorimetric determinations of aqueous sodium chloride heat capacity, integral heat",
      "title": "ØCJ",
      "url": "https://srd.nist.gov/JPCRD/jpcrd272.pdf"
    },
    {
      "type": "text_result",
      "domain": "ndl.ethernet.edu.et",
      "ref_id": "turn0search15",
      "snippet": "Using Kirchhoff’s law, the enthalpy of reaction can be calculated for any arbitrary temperature, provided that the heat capacities of the components are known for",
      "title": "3.5 Enthalpy of reaction 119",
      "url": "https://ndl.ethernet.edu.et/bitstream/123456789/62579/1/2005_Book_ThermodynamicsInMineralScience.pdf"
    },
    {
      "type": "text_result",
      "domain": "www.sciencedirect.com",
      "ref_id": "turn0search2",
      "snippet": "# The apparent molar heat capacities and volumes of aqueous NaCl from 0.01 to 3 mol kg^{−1} in the temperature range 274.65 to 318.15 K",
      "title": "The apparent molar heat capacities and volumes of aqueous NaCl from 0.01 to 3 mol kg−1 in the temperature range 274.65 to 318.15 K",
      "url": "https://www.sciencedirect.com/science/article/pii/0021961475900397"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search3",
      "snippet": "Physical Chemistry (LibreText) ... Equation \\ref{EQ1} is often referred to as Kirchhoff's Law. ... If the temperature dependence of the heat capacity is known, it",
      "title": "19.13: The Temperature Dependence of ΔH - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/Physical_Chemistry_%28LibreTexts%29/19%3A_The_First_Law_of_Thermodynamics/19.13%3A_The_Temperature_Dependence_of_H"
    },
    {
      "type": "text_result",
      "domain": "www.sciencedirect.com",
      "ref_id": "turn0search4",
      "snippet": "The difference in heat capacity between water and 0.0150 mol·kg^{−1} NaCl(aq) was measured from 604 to 718 K at 32 MPa with a modified flow",
      "title": "Heat capacities of 0.0150 mol·kg−1 NaCl(aq) from 604 to 718 K at 32 MPa",
      "url": "https://www.sciencedirect.com/science/article/pii/0021961488901516"
    },
    {
      "type": "text_result",
      "domain": "www.sciencedirect.com",
      "ref_id": "turn0search5",
      "snippet": "# Heat capacity of aqueous sodium chloride from 320 to 600 K measured with a new flow calorimeter ... The ratio of the heat capacity",
      "title": "Heat capacity of aqueous sodium chloride from 320 to 600 K measured with a new flow calorimeter",
      "url": "https://www.sciencedirect.com/science/article/pii/0021961481900045"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search6",
      "snippet": "9.2.52), we can write \\begin{equation} \\Pd{\\Delsub{r}H}{T}{p, \\xi} = \\Pd{\\sum_i\\nu_i H_i}{T}{p, \\xi} = \\sum_i\\nu_i C_{p,i} = \\Delsub{r}C_p \\tag{11.3.5} \\end{equation} where \\(\\Delsub{r}C_p\\) is the mo",
      "title": "11.3: Molar Reaction Enthalpy - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Bookshelves/Physical_and_Theoretical_Chemistry_Textbook_Maps/DeVoes_Thermodynamics_and_Chemistry/11%3A_Reactions_and_Other_Chemical_Processes/11.03%3A_Molar_Reaction_Enthalpy"
    },
    {
      "type": "text_result",
      "domain": "link.springer.com",
      "ref_id": "turn0search7",
      "snippet": "# Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associated with the Partial Molar Heat Capacity",
      "url": "https://link.springer.com/article/10.1007/s10953-024-01412-5"
    },
    {
      "type": "text_result",
      "domain": "www.nist.gov",
      "ref_id": "turn0search8",
      "snippet": "The heat capacities of water and NaCl(aq) from 0.05 to 6 mol.kg^{-1} were measured from 285 K to a lower temperature of 202 K 2O",
      "title": "Thermodynamic Properties of the NaCl + H2O System. 4. Heat Capacities of H2O and NaCl(aq) in Cold-Stable and Supercooled States",
      "url": "https://www.nist.gov/publications/thermodynamic-properties-nacl-h2o-system-4-heat-capacities-h2o-and-naclaq-cold-stable"
    },
    {
      "type": "text_result",
      "domain": "doi.org",
      "ref_id": "turn0search9",
      "snippet": "This accuracy was verified with the unpublished results of part 2 of this study, which considers the heat capacities of aqueous NaCl solutions. ... The",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities Associated with the Partial Molar Enthalpy",
      "url": "https://doi.org/10.1007/s10953-023-01322-y"
    },
    {
      "type": "text_result",
      "domain": "www.sciencedirect.com",
      "ref_id": "turn0search10",
      "snippet": "The difference in heat capacity between water and 0.0150 mol·kg^{−1} NaCl(aq) was measured from 604 to 718 K at 32 MPa with a modified flow",
      "title": "Heat capacities of 0.0150 mol·kg−1 NaCl(aq) from 604 to 718 K at 32 MPa",
      "url": "https://www.sciencedirect.com/science/article/abs/pii/0021961488901516"
    },
    {
      "type": "text_result",
      "domain": "chem.libretexts.org",
      "ref_id": "turn0search11",
      "snippet": "However, if the heat capacity is independent of temperature (as it is for an ideal gas), we can take \\(\\bf{\\Delta_r C_p}\\) out of the integral",
      "title": "1.3: Thermochemistry - Chemistry LibreTexts",
      "url": "https://chem.libretexts.org/Courses/Western_Washington_University/Biophysical_Chemistry_%28Smirnov_and_McCarty%29/01%3A_Biochemical_Thermodynamics/1.03%3A_Thermochemistry"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search16",
      "snippet": "Standard molar entropy, ... Heat capacity, c_{p} | 50 J/(mol·K) ; 0.853 J/(g·K) ... Sodium chloride (data page) ## Density data of aqueous solutions ...",
      "title": "Sodium chloride (data page)",
      "url": "https://en.wikipedia.org/wiki/Sodium_chloride_%28data_page%29"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search17",
      "snippet": "Molar mass | 58.44 g·mol^{-1} ... Heat capacity (C) ... ### Aqueous solutions ... When dissolved in water, the sodium chloride framework disintegrates as the",
      "title": "Sodium chloride",
      "url": "https://en.wikipedia.org/wiki/Sodium_chloride"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search18",
      "snippet": "the standard enthalpy of reaction ${\\displaystyle \\Delta H_{\\text{reaction}}^{\\ominus }}$ is related to the standard enthalpy of formation ${\\displaystyle \\Delta _{\\text{f}}H^{\\ominus }}$ values of th",
      "title": "Standard enthalpy of reaction",
      "url": "https://en.wikipedia.org/wiki/Standard_enthalpy_of_reaction"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search19",
      "snippet": "## Water with dissolved NaCl ... Note: ρ is density, n is refractive index at 589 nm, and η is viscosity, all at 20 °C;",
      "title": "Water (data page)",
      "url": "https://en.wikipedia.org/wiki/Water_%28data_page%29"
    }
  ]
}
assistant
The earlier assumption \(S\ge0\) is unjustified: \(S\) must represent the solution’s total heat capacity minus that of the original water, not just the solid salt’s heat capacity. I’ll allow either sign while requiring \(C+S>0\). I’ll also define dissolution energy at the salt’s initial temperature. The revised model gives conditional timing regimes—earliest, latest, an interior temperature, or a comparison of the endpoints—rather than a universal “add now” recommendation.
shell input
{
  "command": "/usr/bin/bash -lc 'cat checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json diagnostics/cycle2-check-1.txt history/cycle1/candidate.json'"
}
shell output · exit 0
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:26:03.961421+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
{
 "file": "/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean",
 "conclusions": [
  "addition_timing_answer"
 ],
 "lean_exit": 0,
 "ok": true,
 "compiles_alone": true,
 "faithful": {
  "addition_timing_answer": true
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
  "heatingTime",
  "boilingTime"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "addition_timing_answer": {
   "original_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16",
   "extracted_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16"
  }
 },
 "dependency_faithful": {
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "netPower": true,
  "mixedTemperature": true,
  "boilingTime": true,
  "heatingTime": true
 },
 "dependency_identities": {
  "initialTemperature": {
   "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
   "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
  },
  "initialTemperature._proof_1": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "netPower": {
   "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
   "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
  },
  "mixedTemperature": {
   "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
   "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
  },
  "boilingTime": {
   "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
   "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
  },
  "heatingTime": {
   "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
   "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "addition_timing_answer": "\u2200 (C S H Ts B W k A x : \u211d), 0 < C \u2192 0 \u2264 S \u2192 0 \u2264 H \u2192 Ts \u2264 initialTemperature \u2192 0 < k \u2192 0 < netPower W k A B \u2192 initialTemperature \u2264 x \u2192 x \u2264 B \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 netPower W k A x \u2264 netPower W k A (mixedTemperature C S H Ts x) \u2227 boilingTime C S H Ts B W k A initialTemperature \u2264 boilingTime C S H Ts B W k A x \u2227 heatingTime C W k A initialTemperature initialTemperature = 0"
 },
 "extracted_file": "/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean",
 "errors": []
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T14:22:00.296935+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16",
        "extracted_sha256": "9fa908628bc17830cc01af0a555beac02591fa217d7f4e9e68a91b3f9343da16"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "netPower": true,
      "mixedTemperature": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B W k A x : \u211d), 0 < C \u2192 0 \u2264 S \u2192 0 \u2264 H \u2192 Ts \u2264 initialTemperature \u2192 0 < k \u2192 0 < netPower W k A B \u2192 initialTemperature \u2264 x \u2192 x \u2264 B \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 netPower W k A x \u2264 netPower W k A (mixedTemperature C S H Ts x) \u2227 boilingTime C S H Ts B W k A initialTemperature \u2264 boilingTime C S H Ts B W k A x \u2227 heatingTime C W k A initialTemperature initialTemperature = 0"
    },
    "extracted_file": "/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "addition_timing_answer"
  },
  "user_facts": [
    "1 litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.",
    "Salt will be added; its amount and the pot, heater and room conditions are unspecified."
  ],
  "model_choices": [
    "Deterministic lumped calorimetry with constant water-plus-pot capacity C>0 and additive salt contribution S>=0; pot initially at 20 C.",
    "Compare fixed salt amount, salt initial temperature Ts, dissolution energy H, pressure and final boiling temperature B across schedules; all remain symbolic and unestimated.",
    "Instantaneous complete dissolution and mixing; no material loss, evaporation, phase change before endpoint, mixing delay or stove interruption. Only physically feasible pre-boiling addition schedules apply.",
    "Constant positive net powers P before salting and Q afterward, identical across compared schedules; equal powers is a conditional special case, not inferred from the data."
  ],
  "sources": [
    "https://openstax.org/books/university-physics-volume-2/pages/1-4-heat-transfer-specific-heat-and-calorimetry",
    "https://openstax.org/books/chemistry-2e/pages/11-4-colligative-properties"
  ],
  "incorporated_inputs": [],
  "proof_scope": "Derives total boiling time from preheating, mixing/dissolution and postheating energy balances. Proves the exact earlier/later/equal timing comparison according to the sign of Q-P, and the temperature-independent time for equal net powers. Does not estimate any physical parameters or establish model applicability, a unique real-world optimum, or human approval."
}
web_search input
{
  "query": "https://doi.org/10.1007/s10953-023-01322-y",
  "action": {
    "type": "open_page",
    "url": "https://doi.org/10.1007/s10953-023-01322-y"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "doi.org",
      "ref_id": "turn1view0",
      "snippet": "Total lines: 611",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/zzCh4tpaKUSGyekE93FfuMs8cAzDflvQ7D9eyMozoGTW-m_7sp2xndUhLYqfC32MsLkPx-rhXR9B_imbJ4b9_Sl6OJmEFKdKvokp19thLjJNxgYoxVGHjLOIatedI6mif4vJ3PMQ8FViKKjNnoA5Ws4qxcf-Qz9wrBDfOwPG_n3Iqn6S4N_vqoy9bFsqHsYaLeRV2Ye4T1DSWwcRV_682w",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities Associated with the Partial Molar Enthalpy | Journal of Solution Chemistry | Springer Nature Link",
      "url": "https://doi.org/10.1007/s10953-023-01322-y"
    },
    {
      "type": "text_result",
      "domain": "link.springer.com",
      "ref_id": "turn1view1",
      "snippet": "Total lines: 571",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/VYDPq1BtWWZzJzl8IzwwK2NbWZTSDUauFEmaw7K-hC71_MB9dm7WnnNeXKx4HgBbupE1HgmEjyW-mvOWeW28p5yM9eTaAjeW8o6wU8iOk6rNeOuGva4C7Hd3HoQdoyjWel-gp7Qk1rmG5U5SHOPZdKwaLgYlVAPKQOXG41f0cLCgHOAp3gFgtgGL4TvmVMg-U9sddHYUi6LOV_2vtXKh7Q",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associated with the Partial Molar Heat Capacity | Journal of Solution Chemistry | Springer Nature Link",
      "url": "https://link.springer.com/article/10.1007/s10953-024-01412-5"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc 'mkdir -p history/cycle2 && cp Model.lean report.txt candidate.json human-feedback.json history/cycle2/'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='Model.lean'\ns=open(p).read().split('/- Positive net power up to B,')[0]\ns=s.replace('S the additional capacity, Ts salt temperature, H dissolution\\\\n   energy absorbed.', 'S = final solution capacity minus original water capacity (signed),\\\\n   Ts salt temperature and enthalpy reference, H dissolution energy at Ts.')\ns=s.replace('/- Derive the mixing balance rather than assuming a cooling amount. -/', '''/- H is the isothermal dissolution energy at Ts, not at every x.\n   If cs is solid salt capacity, Kirchhoff gives dissolution energy\n   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).\n   Thus their sum is H+S*(x-Ts), for either sign of S. -/\nlemma reference_consistent_balance :\n    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →\n    ((C + S) * (z - x) + cs * (x - Ts) +\n      (H + (S - cs) * (x - Ts)) = 0 ↔\n      z = mixedTemperature C S H Ts x) := by\n  intro C S H Ts cs x z hc\n  unfold mixedTemperature\n  rw [eq_div_iff hc]\n  constructor <;> intro h <;> nlinarith\n\n/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/''')\nopen(p,'w').write(s)\nPY\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"cat >> Model.lean <<'EOF'\n/- The derivative has precisely the sign of the net cooling energy\n   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/\nlemma timing_derivative_signed :\n    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →\n    netPower W k A x ≠ 0 →\n    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →\n    HasDerivAt (boilingTime C S H Ts B W k A)\n      (C * (k * (S * (x - Ts) + H) / (C + S)) /\n        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by\n  intro C S H Ts B W k A x hc hk hx hz\n  have hj := power_change C S H Ts W k A x hc\n  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =\n      C * (k * (S * (x - Ts) + H) / (C + S)) /\n        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by\n    rw [← hj]\n    field_simp\n    <;> ring\n  rw [← he]\n  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz\n\n/- Constant-capacity mixing is increasing in the addition temperature,\n   even if S<0. Endpoint constraints keep the entire trajectory liquid.\n   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/\nlemma feasible_trajectory :\n    ∀ (C S H Ts B W k A F B0 L U y : ℝ),\n    0 < C → 0 < C + S → 0 < k →\n    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →\n    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →\n    0 < netPower W k A U → 0 < netPower W k A B →\n    y ∈ Set.Icc L U →\n    (initialTemperature ≤ y ∧ y ≤ B0) ∧\n    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧\n    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by\n  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy\n  have hzmono : Monotone (mixedTemperature C S H Ts) := by\n    intro a b hab\n    unfold mixedTemperature\n    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)\n  have hzlo := le_trans hzl (hzmono hy.1)\n  have hzhi := le_trans (hzmono hy.2) hzu\n  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩\n  unfold netPower at *\n  constructor <;> nlinarith\n\n/- Comparing stages on any feasible subinterval, using the derived sign. -/\nlemma time_increasing_on_cooling :\n    ∀ (C S H Ts B W k A u v : ℝ),\n    0 < C → 0 < C + S → 0 < k → u ≤ v →\n    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧\n      0 < netPower W k A (mixedTemperature C S H Ts y)) →\n    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →\n    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by\n  intro C S H Ts B W k A u v hC hc hk huv hp hs\n  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y\n    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)\n  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by\n    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)\n    · intro y hy\n      exact (hd y hy).continuousAt.continuousWithinAt\n    · intro y hy\n      exact (hd y (interior_subset hy)).hasDerivWithinAt\n    · intro y hy\n      have hm := interior_subset hy\n      exact div_nonneg (mul_nonneg (le_of_lt hC)\n        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))\n        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))\n  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv\n\nlemma time_decreasing_on_warming :\n    ∀ (C S H Ts B W k A u v : ℝ),\n    0 < C → 0 < C + S → 0 < k → u ≤ v →\n    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧\n      0 < netPower W k A (mixedTemperature C S H Ts y)) →\n    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →\n    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by\n  intro C S H Ts B W k A u v hC hc hk huv hp hs\n  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y\n    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)\n  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by\n    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)\n    · intro y hy\n      exact (hd y hy).neg.continuousAt.continuousWithinAt\n    · intro y hy\n      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt\n    · intro y hy\n      have hm := interior_subset hy\n      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /\n          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=\n        div_nonpos_of_nonpos_of_nonneg\n          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)\n            (div_nonpos_of_nonpos_of_nonneg\n              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))\n          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))\n      exact neg_nonneg.mpr hn\n  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv\n  linarith\n\n/- Conditional scientific answer over an explicitly feasible interval.\n   S>=0: earliest, latest, or interior root as D changes sign.\n   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.\n   H is allowed either sign; mixing need not cool or increase net power. -/\ntheorem addition_timing_answer :\n    ∀ (C S H Ts B W k A F B0 L U x : ℝ),\n    0 < C → 0 < C + S → 0 < k →\n    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →\n    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →\n    0 < netPower W k A U → 0 < netPower W k A B →\n    x ∈ Set.Icc L U →\n    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =\n      k * (S * (x - Ts) + H) / (C + S)) ∧\n    (0 ≤ S → 0 ≤ S * (L - Ts) + H →\n      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧\n    (0 ≤ S → S * (U - Ts) + H ≤ 0 →\n      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧\n    (0 < S → Ts - H / S ∈ Set.Icc L U →\n      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧\n    (S ≤ 0 →\n      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤\n        boilingTime C S H Ts B W k A x) ∧\n    (S = 0 → H = 0 →\n      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by\n  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx\n  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧\n      0 < netPower W k A (mixedTemperature C S H Ts y) := by\n    intro y hy\n    exact (feasible_trajectory C S H Ts B W k A F B0 L U y\n      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2\n  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →\n      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →\n      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by\n    intro u v hlu hvu huv hs\n    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv\n    · intro y hy\n      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩\n    · exact hs\n  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →\n      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →\n      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by\n    intro u v hlu hvu huv hs\n    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv\n    · intro y hy\n      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩\n    · exact hs\n  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩\n  · intro hS hD\n    apply inc L x (le_refl _) hx.2 hx.1\n    intro y hy\n    nlinarith [hy.1]\n  · intro hS hD\n    apply dec x U hx.1 (le_refl _) hx.2\n    intro y hy\n    nlinarith [hy.2]\n  · intro hS hr\n    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by\n      field_simp\n      <;> ring\n    by_cases hxr : x ≤ Ts - H / S\n    · apply dec x (Ts - H / S) hx.1 hr.2 hxr\n      intro y hy\n      nlinarith [hy.2]\n    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)\n      intro y hy\n      nlinarith [hy.1]\n  · intro hS\n    by_cases hD : 0 ≤ S * (x - Ts) + H\n    · apply le_trans (min_le_left _ _)\n      apply inc L x (le_refl _) hx.2 hx.1\n      intro y hy\n      nlinarith [hy.2]\n    · apply le_trans (min_le_right _ _)\n      apply dec x U hx.1 (le_refl _) hx.2\n      intro y hy\n      have hh := le_of_not_ge hD\n      nlinarith [hy.1]\n  · intro hS hH\n    apply le_antisymm\n    · apply inc L x (le_refl _) hx.2 hx.1\n      intro y hy\n      simp [hS, hH]\n    · apply dec L x (le_refl _) hx.2 hx.1\n      intro y hy\n      simp [hS, hH]\nEOF\nsource /work/lean-env.sh\nwhich lean\nlean Model.lean > diagnostics/cycle3-compile-1.log 2>&1\""
}
shell output · exit 127 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'ls /opt /harness /root/.elan/bin /home/[user]/.elan/bin'"
}
shell output · exit 2 · failed
ls: cannot access '/root/.elan/bin': Permission denied
ls: cannot access '/home/[user]/.elan/bin': No such file or directory
/harness:
entrypoint.sh
lean-toolchain
src

/opt:
lean
shell input
{
  "command": "/usr/bin/bash -lc 'cat diagnostics/cycle3-compile-1.log diagnostics/cycle2-compile-4.log'"
}
shell output · exit 0
/usr/bin/bash: line 187: lean: command not found
Model.lean:95:37: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:99:34: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:95:37: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
Model.lean:99:34: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /opt/lean /work/../harness'"
}
shell output · exit 0
/opt/lean:
total 124
drwxr-xr-x 7 1001 1001  4096 Oct 15 19:13 .
drwxr-xr-x 1 root root  4096 Nov 17 15:42 ..
-rw-r--r-- 1 1001 1001  9160 Oct 12 16:23 LICENSE
-rw-r--r-- 1 1001 1001 81940 Oct 12 16:23 LICENSES
drwxr-xr-x 2 1001 1001  4096 Oct 15 19:13 bin
drwxr-xr-x 4 1001 1001  4096 Oct 15 19:13 include
drwxr-xr-x 5 1001 1001  4096 Oct 15 19:13 lib
drwxr-xr-x 3 1001 1001  4096 Oct 15 19:13 share
drwxr-xr-x 3 1001 1001  4096 Oct 15 19:13 src

/work/../harness:
total 24
drwxr-xr-x 4 root root 4096 Nov 17 15:42 .
drwxr-xr-x 1 root root 4096 Nov 17 15:42 ..
drwxr-xr-x 3 root root 4096 Nov 17 15:42 .lake
-rwxrwxr-x 1 1001 1001  689 Nov 16 18:09 entrypoint.sh
-rw-rw-r-- 1 1001 1001   25 Nov 16 18:09 lean-toolchain
drwxr-xr-x 2 root root 4096 Nov 17 15:42 src
shell input
{
  "command": "/usr/bin/bash -lc 'find /opt/lean -maxdepth 4 -name lean -o -name Mathlib -o -name lake'"
}
shell output · exit 0
/opt/lean
/opt/lean/include/lean
/opt/lean/bin/lean
/opt/lean/bin/lake
/opt/lean/share/lean
/opt/lean/src/lean
/opt/lean/src/lean/include/lean
/opt/lean/src/lean/lake
/opt/lean/lib/lean
shell input
{
  "command": "/usr/bin/bash -lc 'source /work/lean-env.sh\n/opt/lean/bin/lean Model.lean > diagnostics/cycle3-compile-2.log 2>&1'"
}
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'cat diagnostics/cycle3-compile-2.log'"
}
shell output · exit 0
Model.lean:109:37: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:113:34: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:109:37: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
Model.lean:113:34: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
Model.lean:160:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:160:8: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:160:8: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
Model.lean:186:18: error: linarith failed to find a contradiction
case left
C S H Ts B W k A F B0 L U y : ℝ
hC : 0 < C
hc : 0 < C + S
hk : 0 < k
hF : F ≤ initialTemperature
hi : initialTemperature ≤ L
hLU : L ≤ U
hU : U ≤ B0
hzl : F ≤ mixedTemperature C S H Ts L
hzu : mixedTemperature C S H Ts U ≤ B
hpU : 0 < W - k * (U - A)
hpB : 0 < W - k * (B - A)
hy : y ∈ Set.Icc L U
hzmono : Monotone (mixedTemperature C S H Ts)
hzlo : F ≤ mixedTemperature C S H Ts y
hzhi : mixedTemperature C S H Ts y ≤ B
a✝ : W - k * (y - A) ≤ 0
⊢ False
failed
Model.lean:299:6: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
Model.lean:299:6: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='Model.lean'\ns=open(p).read().replace('constructor <;> nlinarith\\\\n\\\\n/- Comparing stages', 'constructor <;> nlinarith [hy.2]\\\\n\\\\n/- Comparing stages')\nopen(p,'w').write(s)\nPY\nsource /work/lean-env.sh\n/opt/lean/bin/lean Model.lean > diagnostics/cycle3-compile-3.log 2>&1\""
}
shell output · exit 0
assistant
The revised Lean proof compiles locally. Its timing derivative has the sign of \(S(T-T_s)+H\), so it no longer presumes that mixing cools the water or increases net heating power. It also checks that the comparison interval stays below unsalted boiling before addition and within the liquid-mixture range afterward. I’m preparing the review packet before running the required harness check.
web_search input
{
  "query": "'apparent molar heat capacity'",
  "action": {
    "type": "find_in_page",
    "pattern": "apparent molar heat capacity"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "link.springer.com",
      "ref_id": "turn2view0",
      "snippet": "Total lines: 571",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/eUZx2REJYTUmGm1MgQDLRhnfyvYl1I5h-RP6wJM5D4IA8l5Uan6DAao5bdQjJ6Wr1ry7nFBX7e_OHktExZIBZhGntY8VnlxSaBqmYgM0QiUGbqyNAItaKRmkaJUigb60hKum9PQY7IDgmh2242zllurTg-sHJ6ffw-4gd1JvJdFstdnFNyResjI_4r8PJimc6QauLk9jjNMr3sZ2iFWZbw",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associated with the Partial Molar Heat Capacity | Journal of Solution Chemistry | Springer Nature Link",
      "url": "https://link.springer.com/article/10.1007/s10953-024-01412-5"
    },
    {
      "type": "text_result",
      "domain": "doi.org",
      "ref_id": "turn2view1",
      "snippet": "Total lines: 611",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/LeNsc9G_Jf-8PXTudqg1uHRGX-7F7TGOHqp8KyXaeIcQFykw0n2OsJuVuecqQFH4g3NClZqvmGaH0wLtyRkjTFkiFLtI8H0Q9XVIrSRLixRoBEDEbHl6SwnsT_InfR7cP53vXYs_1yhZYlPCP5TwicW1mcvpH4K65LaHZO2riBAJ9dcdsjGBW9dD8w4RMX8m6n9hgf_Jobyt_MpZ1RE6Yg",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities Associated with the Partial Molar Enthalpy | Journal of Solution Chemistry | Springer Nature Link",
      "url": "https://doi.org/10.1007/s10953-023-01322-y"
    },
    {
      "type": "text_result",
      "domain": "link.springer.com",
      "ref_id": "turn2view2",
      "snippet": "Total lines: 571",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/fTGpoTiXeDunqT9TEhGJq_6i28WkYAv61B4c1WKDqR4to-pFHX3vjesc4u_8tKRvir6kXGWdUoEdvoNPhiXUZAmrnkp9sJXCluirICJXlFWP3spcnh1IgL9GZPfjFUwyojzt61RYlAjJM_DxGXI6mNbmQ8UeD_5JhdDPHXGJhTuPrzxGZpnE4q_QZ5q5w6tFodWliKcKy2Xs4JamqsuOvw",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associated with the Partial Molar Heat Capacity | Journal of Solution Chemistry | Springer Nature Link",
      "url": "https://link.springer.com/article/10.1007/s10953-024-01412-5"
    },
    {
      "type": "text_result",
      "domain": "doi.org",
      "ref_id": "turn2view3",
      "snippet": "Total lines: 611",
      "thumbnail_url": "https://images.openai.com/static-rsc-1/d_VjtcWx6MHqVPwR2t8Mdkq4nDKFJqPcXaWDtKF0Cizs2Jc_iQAI-q65YW9FCRHa5HwZon3s670jWOEmqX5lqRAFINfsB8miAPnG-MkdyEdPKn3lql2gDif58COGzU5rUEqUWoDrX6FnSidlkRKdmCGuo3WBcLQqDsg9QEM3qOg_U3rd9R30okqXnDKKfYLYgwnBd390KC9GdpY2Mdp5Sw",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities Associated with the Partial Molar Enthalpy | Journal of Solution Chemistry | Springer Nature Link",
      "url": "https://doi.org/10.1007/s10953-023-01322-y"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '1,90p' Model.lean\""
}
shell output · exit 0
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='Model.lean'\ns=open(p).read().replace('salt is added at unsalted temperature x. The initial cooling and the','salt is added at unsalted temperature x. The mixing temperature jump and the')\nopen(p,'w').write(s)\nPY\ncat > report.txt <<'EOF'\nNo unique addition temperature or heating time follows from the supplied information. The previous unconditional-looking recommendation to add immediately under S>=0 has been withdrawn. This revision proves the full signed-capacity conditional timing regimes within the retained lumped, constant-input, Newtonian-loss approximation. It does not claim that an unspecified salt belongs to a particular regime.\n\nSupplied information and inference limits\n\nThe user supplies one litre of water initially at 20 degrees Celsius, a pot and a stove already heating it, and the intention to add salt. Salt identity, quantity, temperature, pressure, pot, heater and room conditions are unspecified. There are no calorimetric or heating-curve observations. The volume and initial temperature do not identify heat capacities, dissolution energy, heater input, losses, or the final boiling temperature. No exact mass/capacity is invented from the litre. There is no statistical observation model, likelihood or prior: the available inference is deterministic and conditional. No experiment or simulated experiment was performed; no operator response was requested or fabricated; incorporated_inputs is empty.\n\nPhysical model and correct capacity meaning\n\nFix the same soluble salt quantity, salt initial temperature Ts, pressure and final composition across schedules. Treat water and pot as a uniform body initially equilibrated at 20 C. Approximate its capacity C>0 and the final solution-plus-pot capacity C+S>0 as constants over the relevant liquid-temperature range. Here\n  C = original water capacity + pot capacity,\n  S = final solution capacity - original water capacity.\nThe pot contribution cancels in S. S is a signed effective capacity difference, NOT the positive capacity of the solid salt. We impose no sign on S. This is the requested conditional-regimes approach, not an assertion of a sign for all NaCl solutions or any other unspecified salt. For a specified solute with amount n, the thermodynamic definition gives S=n*C_app, where C_app is its apparent molar heat capacity at the specified composition and temperature. That apparent capacity is not the solid's molar capacity. A real solution's S(T) can vary with temperature; the constant-capacity approximation must be tested over the heating range.\n\nPartanen & Partanen, Journal of Solution Chemistry 54, 286-316 (2025), Eq. (9), defines C_app as (solution capacity - pure-water capacity)/solute amount. Their analysis treats its composition and temperature dependence and distinguishes real apparent quantities from relative apparent quantities. This supports the capacity interpretation, not a constant value or sign for the user's water. We import no table values or parameter estimates.\nhttps://link.springer.com/article/10.1007/s10953-024-01412-5\n\nDissolution energy reference and mixing balance\n\nH (joules) is the integral isothermal enthalpy of dissolution of the fixed solid salt amount into the fixed water amount at temperature Ts, the ACTUAL initial salt temperature, with the chosen final concentration. Positive H means endothermic at that reference. H can have either sign. It is a fixed reference enthalpy, not a temperature-independent dissolution enthalpy at every addition temperature.\n\nTake the original water-plus-pot enthalpy as zero at Ts and the separate salt's enthalpy as zero at its initial Ts. Under the constant-capacity model, the final solution-plus-pot enthalpy at temperature z is H+(C+S)*(z-Ts). Initial enthalpy just before addition at temperature x is C*(x-Ts). Instantaneous adiabatic mixing/dissolution therefore gives\n  H+(C+S)*(z-Ts) = C*(x-Ts),\n  z(x) = (C*x+S*Ts-H)/(C+S).\nEquivalently, the signed mixing cooling energy is D(x)=S*(x-Ts)+H, and z-x=-D(x)/(C+S). Negative D means WARMING on mixing; no cooling premise is used.\n\nFor consistency, if the solid salt's constant sensible capacity is cs, isothermal dissolution at x costs H+(S-cs)*(x-Ts). This follows by subtracting the reactant capacity C+cs from product capacity C+S and integrating the enthalpy slope. Warming the solid from Ts to x costs cs*(x-Ts); the sum is H+S*(x-Ts). The Lean lemma reference_consistent_balance proves that the resulting balance (C+S)*(z-x)+cs*(x-Ts)+H+(S-cs)*(x-Ts)=0 is equivalent to the displayed z(x). Thus a positive solid heat capacity does not force S>=0. cs cancels and is not an independent parameter needed by the timing conclusion. These affine enthalpy laws are modeling choices; the algebraic consequence is proved. Temperature-dependent capacities would require integrating their actual functions.\n\nPartanen & Partanen, Journal of Solution Chemistry 52, 1352-1385 (2023), Section 2, treats apparent enthalpy, dissolution and adiabatic temperature changes with explicit reference quantities. It provides general thermodynamic background only, not evidence for this pot's H or an exact constant-capacity law.\nhttps://link.springer.com/article/10.1007/s10953-023-01322-y\n\nHeating law and feasible timing domain\n\nThe retained approximation is constant heater-to-body power W and fixed room temperature A, with the SAME Newtonian heat loss k*(T-A) before and after addition, k>0. Hence net power is N(T)=W-k*(T-A). Salt does not change W or k at a common temperature in this approximation. The energy law is capacity*dT/dt=N(T), with capacity C before addition and C+S afterward. This model omits evaporation, radiation beyond the effective linear approximation, changes in heat transfer with concentration, heater feedback, material loss, stirring delay and dissolution delay. Mixing and complete dissolution are instantaneous with no heater pause. These are exposed approximations, not inferred facts about the apparatus.\n\nB0 denotes the unsalted boiling temperature and B the fixed final mixture boiling temperature, both at the chosen pressure. F is a common SAFE liquid lower bound for both compositions over the applicable trajectories (choose it within the liquid region, not below either freezing boundary). L and U bound the interval of feasible addition temperatures. The final theorem requires:\n  F <= 20 <= L <= U <= B0;\n  F <= z(L) and z(U) <= B;\n  N(U)>0 and N(B)>0;\n  C>0, C+S>0, k>0.\nThe assumptions do not allow waiting through unsalted boiling. U=B0 permits adding at its onset, without dwelling there. Similarly z(U)=B permits the final endpoint to occur on mixing, without an intervening boiling/evaporation stage. If strict pre-boiling addition is required and U=B0 is excluded, a latest-endpoint optimum becomes an infimum approached from below, unless a smaller closed operational upper bound is selected.\n\nThe lemma feasible_trajectory derives that z is increasing (slope C/(C+S)>0) irrespective of S's sign. Therefore every x in [L,U] satisfies 20<=x<=B0 and F<=z(x)<=B, and both stages have positive net heating throughout. Unsalted water heats from 20 to x, and the mixture heats from z(x) to B, remaining liquid until each relevant endpoint. Solubility and absence of intermediate phase changes during the instantaneous idealized mixing are independent physical applicability requirements. If the full feasible set is nonempty under these affine constraints it is an interval; L and U should be its endpoints if optimizing over all feasible schedules. A deliberately narrower interval gives an optimum only over that interval. If even immediate mixing is too cold or too hot for these constraints, a conclusion at L=20 is not authorized.\n\nDerived power change, elapsed times, and optimization\n\nApplying the same N to the energy-conserving mixing temperature gives the proved power_change identity:\n  N(z(x))-N(x) = k*[S*(x-Ts)+H]/(C+S) = k*D(x)/(C+S).\nSince k>0 and C+S>0, net power increases exactly for cooling (D>0), decreases for warming (D<0), and is unchanged for D=0. There are no unrelated before/after powers. A net-power increase alone does not compare heating rates because capacity also changes.\n\nWith positive net power, integration of dt/dT=capacity/N(T) gives\n  heatingTime(capacity,u,v) = capacity/k * log[N(u)/N(v)].\nThe Lean definition uses a difference of logarithms; the ratio is dimensionless. All numerical arguments use SI powers and temperatures in C. heating_time_derivative verifies the inverse first-law derivative, and stage_time_from_energy proves that any differentiable inverse elapsed-time curve with this derivative and zero initial value has exactly this endpoint time. This supplies an energy-law derivation and uniqueness, not just arithmetic for an assumed answer.\n\nTotal time to salted boiling for addition at x is\n  t(x) = heatingTime(C,20,x) + heatingTime(C+S,z(x),B).\nWaiting time BEFORE adding salt is heatingTime(C,20,x), not t(x). In particular x=20 gives zero waiting. The proof differentiates the full t, including z'(x)=C/(C+S), obtaining\n  t'(x)=C/N(x)-C/N(z(x))\n        = C*k*D(x)/[(C+S)*N(x)*N(z(x))].\nThus t' has exactly the sign of D(x), even when S<0. The Mean Value Theorem then proves global comparisons on the feasible interval, rather than just a stationary-point test.\n\nThe sole final theorem addition_timing_answer quantifies C,S,H,Ts,B,W,k,A,F,B0,L,U,x, under precisely the displayed feasibility and positivity inequalities and x in [L,U]. Its conclusion is the derived power-jump identity and these five conditional comparisons:\n\n1. If S>=0 and D(L)>=0, then t(L)<=t(x): choose the earliest feasible temperature L.\n2. If S>=0 and D(U)<=0, then t(U)<=t(x): choose the latest feasible temperature U.\n3. If S>0 and r=Ts-H/S lies in [L,U], then t(r)<=t(x): choose that interior root or endpoint. For S>0 this is equivalently clamping r to [L,U], using cases 1 and 2 when r lies outside.\n4. If S<=0, then min(t(L),t(U))<=t(x): compare the two explicit total-time formulas and choose the endpoint with the smaller value. An interior zero of D is a maximum when S<0, not the minimum. The proof handles either sign of D at x and compares along the appropriate subinterval.\n5. If S=0 and H=0, then t(L)=t(x): all feasible schedules tie. For S=0,H>0 case 1 chooses earliest; for S=0,H<0 case 2 chooses latest.\n\nThese weak inequalities allow ties. They give no numerical time saving or unique optimum. In the distinct lossless limit k=0 all schedules tie in this constant-input calorimetric model, since the required energy C*(B-20)+S*(B-Ts)+H is timing independent. This limit is explanatory and is not a submitted theorem; the logarithmic definitions are used only for k>0.\n\nCompact review packet\n\nSupplied: one litre, 20 C start, pot on stove, unspecified salt and apparatus.\nAdditional choices: fixed soluble amount/composition/pressure/Ts; uniform pot-water body initially at 20; constant ORIGINAL capacity C>0 and final capacity C+S>0 with signed S; H referenced at Ts; affine enthalpies; shared constant-input Newton-loss law with k>0; instantaneous complete dissolution with no phase/material losses or delays. Feasible domain and positive-power endpoint constraints are explicit above. No empirical sign for S or H is assumed or inferred.\nNecessary definitions in Lean: initialTemperature=20; netPower=N; mixedTemperature=z; heatingTime=integrated inverse first law; boilingTime=t. D and r are prose abbreviations only and are expanded in the final theorem. F,B0,L,U are direct scalar binders, not wrapper predicates. There are no additional axioms or sorry. Algebra, trajectory bounds, logarithmic integration and derivative signs are intermediate proved facts, not review assumptions.\nProved conclusion: exactly the power-change identity and five timing regimes listed above, with the stated domain. It is a conditional scientific answer; it does not establish that these approximations fit the actual pot or identify which regime applies. Measurements or literature for specified salt mass, composition, H at Ts and solution heat capacity across the temperature range, together with a calibrated heating curve and pressure, would select and test a regime. Salt temperature and feasible endpoints also matter. A numerical number of seconds requires C,W,k,A and the selected addition temperature; none are supplied. No human acceptance is claimed.\n\nLineage and checks\n\nCycle 1 left independent before/after powers and was rejected after formal verification; its files remain in history/cycle1. Cycle 2 used one shared heat-transfer law but assumed nonnegative additive S and insufficiently specified H's reference; its checked mathematical implication was rejected by the human for those scientific reasons. The submitted cycle-2 files and rejection are preserved in history/cycle2. This cycle retains the accepted heat-transfer approximation but corrects S, H and the feasible timing domain and replaces the old recommendation with complete conditional regimes. Prior checks and diagnostics were read, including the earlier independent-extraction failure and subsequent faithful extraction result. Raw traces remain unchanged.\n\nCycle-3 local logs are diagnostics/cycle3-compile-1.log (Lean not on PATH), cycle3-compile-2.log (missing explicit interval endpoint bound in an inequality tactic), and cycle3-compile-3.log (compiles). These are implementation corrections, not model changes. The required actual harness check is run against candidate.json after this report is written. Its raw trace and check directory are the authority for verification status. A successful Lean check establishes the implication from the displayed premises, not their physical truth or human approval.\nEOF\npython - <<'PY'\nimport json\ncandidate={\n'proof_file':'Model.lean','narrative_file':'report.txt',\n'conclusions':{'answer':'addition_timing_answer'},\n'user_facts':['One litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.','Salt will be added; salt quantity, pot, heater and room conditions are otherwise unspecified.'],\n'model_choices':[\n'Deterministic lumped constant-capacity model with original water-plus-pot C>0 and final solution-plus-pot C+S>0; S is the signed solution-minus-water capacity difference, never assumed nonnegative. Pot initially equilibrated at 20 C.',\n'Fixed soluble salt amount, final composition, pressure, salt temperature Ts, unsalted boiling B0 and solution boiling B across schedules. H is integral isothermal dissolution enthalpy at Ts (either sign); affine enthalpies imply dissolution enthalpy H+(S-cs)*(T-Ts) at T for solid salt capacity cs, not a constant dissolution heat at all temperatures.',\n'Instantaneous adiabatic mixing and complete dissolution; no heating interruption, evaporation, phase changes before endpoint or material loss. Constant capacities and the liquid/soluble regime are conditional approximations, not inferred material properties.',\n'Shared before/after net power N(T)=W-k*(T-A), constant heater input and room temperature, k>0; no independent salinity dependence of heat transfer. Heating obeys capacity*dT/dt=N(T).',\n'Compare a nonempty feasible interval [L,U] with F<=20<=L<=U<=B0, F<=z(L), z(U)<=B, N(U)>0 and N(B)>0. F is a safe common liquid lower bound; these constraints enforce liquid heating stages. Endpoint onsets of boiling are permitted without dwelling. Use full feasible interval for a global physical scheduling optimum.'\n],\n'sources':['https://link.springer.com/article/10.1007/s10953-024-01412-5','https://link.springer.com/article/10.1007/s10953-023-01322-y'],\n'incorporated_inputs':[],\n'proof_scope':'Derives reference-consistent mixing balance with signed heat-capacity change, the net-power jump from the shared heater/loss law, stage-time integration and uniqueness from the inverse first law, and the derivative of full boiling time. Proves global earliest/latest/interior-root regimes for S>=0 and endpoint minimum for S<=0, including the S=H=0 tie, on an explicitly feasible liquid interval. No parameter values or material-property signs are inferred from absent observations; physical validity and regime selection remain for human review. No additional axioms, sorry, external responses, experiments or human approval are claimed.'}\nopen('candidate.json','w').write(json.dumps(candidate,indent=2)+'\\\\n')\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json > diagnostics/cycle3-check-1.txt 2>&1\""
}
shell input
{
  "command": "/usr/bin/bash -lc 'tail -c 2500 diagnostics/cycle3-check-1.txt'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"find checks -maxdepth 2 -name verdict.json -printf '%T@ %p\\\\n'\""
}
shell output · exit 0
1794853665.3623644280 checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
1794925337.1677283020 checks/19e916da3a2f417381acb479d8151af9/verdict.json
1794853546.5719799280 checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
1794853580.0500927050 checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
shell input
{
  "command": "/usr/bin/bash -lc \"find checks -maxdepth 2 -type f -mmin -3 -printf '%p\\\\n'\""
}
shell output · exit 0
checks/8ce875bbeedf40f384474d008e4dfa66/submitted-report.txt
checks/8ce875bbeedf40f384474d008e4dfa66/submitted-candidate.json
checks/8ce875bbeedf40f384474d008e4dfa66/lean.log
checks/8ce875bbeedf40f384474d008e4dfa66/extracted.probe.lean
checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'tail -c 2000 checks/8ce875bbeedf40f384474d008e4dfa66/lean.log'"
}
shell output · exit 0
n:109:37: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean:113:34: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean:109:37: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean:113:34: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean:160:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean:160:8: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean:160:8: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean:299:6: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean:299:6: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
'addition_timing_answer' depends on axioms: [propext, Classical.choice, Quot.sound]
VAS_LISTED

leanchecker exit 0

shell input
{
  "command": "/usr/bin/bash -lc 'cat diagnostics/cycle3-check-1.txt checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json'"
}
shell output · exit 0
{
 "file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean",
 "conclusions": [
  "addition_timing_answer"
 ],
 "lean_exit": 0,
 "ok": true,
 "compiles_alone": true,
 "faithful": {
  "addition_timing_answer": true
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
  "heatingTime",
  "boilingTime"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "addition_timing_answer": {
   "original_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00",
   "extracted_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00"
  }
 },
 "dependency_faithful": {
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "mixedTemperature": true,
  "netPower": true,
  "boilingTime": true,
  "heatingTime": true
 },
 "dependency_identities": {
  "initialTemperature": {
   "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
   "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
  },
  "initialTemperature._proof_1": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "mixedTemperature": {
   "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
   "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
  },
  "netPower": {
   "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
   "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
  },
  "boilingTime": {
   "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
   "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
  },
  "heatingTime": {
   "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
   "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "addition_timing_answer": "\u2200 (C S H Ts B W k A F B0 L U x : \u211d), 0 < C \u2192 0 < C + S \u2192 0 < k \u2192 F \u2264 initialTemperature \u2192 initialTemperature \u2264 L \u2192 L \u2264 U \u2192 U \u2264 B0 \u2192 F \u2264 mixedTemperature C S H Ts L \u2192 mixedTemperature C S H Ts U \u2264 B \u2192 0 < netPower W k A U \u2192 0 < netPower W k A B \u2192 x \u2208 Set.Icc L U \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 (0 \u2264 S \u2192 0 \u2264 S * (L - Ts) + H \u2192 boilingTime C S H Ts B W k A L \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 \u2264 S \u2192 S * (U - Ts) + H \u2264 0 \u2192 boilingTime C S H Ts B W k A U \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 < S \u2192 Ts - H / S \u2208 Set.Icc L U \u2192 boilingTime C S H Ts B W k A (Ts - H / S) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S \u2264 0 \u2192 min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S = 0 \u2192 H = 0 \u2192 boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x)"
 },
 "extracted_file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean",
 "errors": []
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T15:48:51.378080+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00",
        "extracted_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "mixedTemperature": true,
      "netPower": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B W k A F B0 L U x : \u211d), 0 < C \u2192 0 < C + S \u2192 0 < k \u2192 F \u2264 initialTemperature \u2192 initialTemperature \u2264 L \u2192 L \u2264 U \u2192 U \u2264 B0 \u2192 F \u2264 mixedTemperature C S H Ts L \u2192 mixedTemperature C S H Ts U \u2264 B \u2192 0 < netPower W k A U \u2192 0 < netPower W k A B \u2192 x \u2208 Set.Icc L U \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 (0 \u2264 S \u2192 0 \u2264 S * (L - Ts) + H \u2192 boilingTime C S H Ts B W k A L \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 \u2264 S \u2192 S * (U - Ts) + H \u2264 0 \u2192 boilingTime C S H Ts B W k A U \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 < S \u2192 Ts - H / S \u2208 Set.Icc L U \u2192 boilingTime C S H Ts B W k A (Ts - H / S) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S \u2264 0 \u2192 min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S = 0 \u2192 H = 0 \u2192 boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x)"
    },
    "extracted_file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T15:48:51.378080+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00",
        "extracted_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "mixedTemperature": true,
      "netPower": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B W k A F B0 L U x : \u211d), 0 < C \u2192 0 < C + S \u2192 0 < k \u2192 F \u2264 initialTemperature \u2192 initialTemperature \u2264 L \u2192 L \u2264 U \u2192 U \u2264 B0 \u2192 F \u2264 mixedTemperature C S H Ts L \u2192 mixedTemperature C S H Ts U \u2264 B \u2192 0 < netPower W k A U \u2192 0 < netPower W k A B \u2192 x \u2208 Set.Icc L U \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 (0 \u2264 S \u2192 0 \u2264 S * (L - Ts) + H \u2192 boilingTime C S H Ts B W k A L \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 \u2264 S \u2192 S * (U - Ts) + H \u2264 0 \u2192 boilingTime C S H Ts B W k A U \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 < S \u2192 Ts - H / S \u2208 Set.Icc L U \u2192 boilingTime C S H Ts B W k A (Ts - H / S) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S \u2264 0 \u2192 min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S = 0 \u2192 H = 0 \u2192 boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x)"
    },
    "extracted_file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
assistant
The supplied information does **not determine a unique best temperature or waiting time**.

The revision allows either sign of the heat-capacity change, keeps total capacity positive, and consistently references dissolution energy to the salt’s initial temperature. Within the stated model, the optimum can be earliest, latest, or an interior temperature; for negative capacity change, compare the two feasible endpoints.

[Report](/work/report.txt), [Lean proof](/work/Model.lean), and [candidate manifest](/work/candidate.json) are ready.

The actual check passed compilation, faithful extraction and kernel verification: [verdict](/work/checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json). The scientific assumptions remain subject to human review; no approval is claimed.

Produced code

attempt-003/Model.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
attempt-003/extracted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

def initialTemperature : ℝ := 20

def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B


/-! Conclusions (statements of the proved theorems). -/
def conclusion_addition_timing_answer : Prop := ∀ (C S H Ts B W k A F B0 L U x : ℝ), 0 < C → 0 < C + S → 0 < k → F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 → F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B → 0 < netPower W k A U → 0 < netPower W k A B → x ∈ Set.Icc L U → (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S)) ∧ (0 ≤ S → 0 ≤ S * (L - Ts) + H → boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧ (0 ≤ S → S * (U - Ts) + H ≤ 0 → boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧ (0 < S → Ts - H / S ∈ Set.Icc L U → boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧ (S ≤ 0 → min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤ boilingTime C S H Ts B W k A x) ∧ (S = 0 → H = 0 → boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x)
checks/19e916da3a2f417381acb479d8151af9/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

Round 4

Messages

assistant
I’ll review the prior proof and feedback, then look for verified material-property evidence to determine which timing case applies to a concrete salt-water scenario.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work'"
}
shell output · exit 0
total 76
drwxrwxr-x 5 1001 1001  4096 Nov 17 22:50 .
drwxr-xr-x 1 root root  4096 Nov 17 22:51 ..
-rw-r--r-- 1 1001 1001 14783 Nov 17 15:48 Model.lean
-rw-r--r-- 1 1001 1001  2597 Nov 17 15:48 candidate.json
drwxr-xr-x 7 1001 1001  4096 Nov 17 15:48 checks
drwxr-xr-x 2 1001 1001  4096 Nov 17 15:48 diagnostics
drwxr-xr-x 4 1001 1001  4096 Nov 17 15:43 history
-rw------- 1 1001 1001  2572 Nov 17 22:50 human-feedback.json
-rw------- 1 1001 1001  9249 Nov 17 15:50 last-review-packet.json
-rw-r--r-- 1 1001 1001   456 Nov 17 14:15 lean-env.sh
-rw-r--r-- 1 1001 1001 13467 Nov 17 15:48 report.txt
shell input
{
  "command": "/usr/bin/bash -lc 'find /work/history /work/diagnostics /work/checks -maxdepth 3 -type f'"
}
shell output · exit 0
/work/history/cycle1/report.txt
/work/history/cycle1/human-feedback.json
/work/history/cycle1/Model.lean
/work/history/cycle1/candidate.json
/work/history/cycle2/report.txt
/work/history/cycle2/human-feedback.json
/work/history/cycle2/Model.lean
/work/history/cycle2/candidate.json
/work/diagnostics/extraction-result.txt
/work/diagnostics/cycle3-compile-1.log
/work/diagnostics/probe2.log
/work/diagnostics/extract-trace-1.txt
/work/diagnostics/cycle3-check-1.txt
/work/diagnostics/cycle2-compile-4.log
/work/diagnostics/cycle2-compile-1.log
/work/diagnostics/cycle2-compile-3.log
/work/diagnostics/probe.log
/work/diagnostics/extraction_trace.py
/work/diagnostics/extract-trace-2.txt
/work/diagnostics/extracted.json
/work/diagnostics/cycle2-check-1.txt
/work/diagnostics/cycle3-compile-3.log
/work/diagnostics/extracted.lean
/work/diagnostics/cycle2-compile-2.log
/work/diagnostics/probe2.lean
/work/diagnostics/probe.lean
/work/diagnostics/cycle3-compile-2.log
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-report.txt
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-candidate.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/lean.log
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-report.txt
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-candidate.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/lean.log
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-report.txt
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-candidate.json
/work/checks/19e916da3a2f417381acb479d8151af9/lean.log
/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.json
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/verdict.json
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-report.txt
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-candidate.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-report.txt
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-candidate.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/lean.log
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/candidate.json /work/report.txt'"
}
shell output · exit 0
{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "addition_timing_answer"
  },
  "user_facts": [
    "One litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.",
    "Salt will be added; salt quantity, pot, heater and room conditions are otherwise unspecified."
  ],
  "model_choices": [
    "Deterministic lumped constant-capacity model with original water-plus-pot C>0 and final solution-plus-pot C+S>0; S is the signed solution-minus-water capacity difference, never assumed nonnegative. Pot initially equilibrated at 20 C.",
    "Fixed soluble salt amount, final composition, pressure, salt temperature Ts, unsalted boiling B0 and solution boiling B across schedules. H is integral isothermal dissolution enthalpy at Ts (either sign); affine enthalpies imply dissolution enthalpy H+(S-cs)*(T-Ts) at T for solid salt capacity cs, not a constant dissolution heat at all temperatures.",
    "Instantaneous adiabatic mixing and complete dissolution; no heating interruption, evaporation, phase changes before endpoint or material loss. Constant capacities and the liquid/soluble regime are conditional approximations, not inferred material properties.",
    "Shared before/after net power N(T)=W-k*(T-A), constant heater input and room temperature, k>0; no independent salinity dependence of heat transfer. Heating obeys capacity*dT/dt=N(T).",
    "Compare a nonempty feasible interval [L,U] with F<=20<=L<=U<=B0, F<=z(L), z(U)<=B, N(U)>0 and N(B)>0. F is a safe common liquid lower bound; these constraints enforce liquid heating stages. Endpoint onsets of boiling are permitted without dwelling. Use full feasible interval for a global physical scheduling optimum."
  ],
  "sources": [
    "https://link.springer.com/article/10.1007/s10953-024-01412-5",
    "https://link.springer.com/article/10.1007/s10953-023-01322-y"
  ],
  "incorporated_inputs": [],
  "proof_scope": "Derives reference-consistent mixing balance with signed heat-capacity change, the net-power jump from the shared heater/loss law, stage-time integration and uniqueness from the inverse first law, and the derivative of full boiling time. Proves global earliest/latest/interior-root regimes for S>=0 and endpoint minimum for S<=0, including the S=H=0 tie, on an explicitly feasible liquid interval. No parameter values or material-property signs are inferred from absent observations; physical validity and regime selection remain for human review. No additional axioms, sorry, external responses, experiments or human approval are claimed."
}
No unique addition temperature or heating time follows from the supplied information. The previous unconditional-looking recommendation to add immediately under S>=0 has been withdrawn. This revision proves the full signed-capacity conditional timing regimes within the retained lumped, constant-input, Newtonian-loss approximation. It does not claim that an unspecified salt belongs to a particular regime.

Supplied information and inference limits

The user supplies one litre of water initially at 20 degrees Celsius, a pot and a stove already heating it, and the intention to add salt. Salt identity, quantity, temperature, pressure, pot, heater and room conditions are unspecified. There are no calorimetric or heating-curve observations. The volume and initial temperature do not identify heat capacities, dissolution energy, heater input, losses, or the final boiling temperature. No exact mass/capacity is invented from the litre. There is no statistical observation model, likelihood or prior: the available inference is deterministic and conditional. No experiment or simulated experiment was performed; no operator response was requested or fabricated; incorporated_inputs is empty.

Physical model and correct capacity meaning

Fix the same soluble salt quantity, salt initial temperature Ts, pressure and final composition across schedules. Treat water and pot as a uniform body initially equilibrated at 20 C. Approximate its capacity C>0 and the final solution-plus-pot capacity C+S>0 as constants over the relevant liquid-temperature range. Here
  C = original water capacity + pot capacity,
  S = final solution capacity - original water capacity.
The pot contribution cancels in S. S is a signed effective capacity difference, NOT the positive capacity of the solid salt. We impose no sign on S. This is the requested conditional-regimes approach, not an assertion of a sign for all NaCl solutions or any other unspecified salt. For a specified solute with amount n, the thermodynamic definition gives S=n*C_app, where C_app is its apparent molar heat capacity at the specified composition and temperature. That apparent capacity is not the solid's molar capacity. A real solution's S(T) can vary with temperature; the constant-capacity approximation must be tested over the heating range.

Partanen & Partanen, Journal of Solution Chemistry 54, 286-316 (2025), Eq. (9), defines C_app as (solution capacity - pure-water capacity)/solute amount. Their analysis treats its composition and temperature dependence and distinguishes real apparent quantities from relative apparent quantities. This supports the capacity interpretation, not a constant value or sign for the user's water. We import no table values or parameter estimates.
https://link.springer.com/article/10.1007/s10953-024-01412-5

Dissolution energy reference and mixing balance

H (joules) is the integral isothermal enthalpy of dissolution of the fixed solid salt amount into the fixed water amount at temperature Ts, the ACTUAL initial salt temperature, with the chosen final concentration. Positive H means endothermic at that reference. H can have either sign. It is a fixed reference enthalpy, not a temperature-independent dissolution enthalpy at every addition temperature.

Take the original water-plus-pot enthalpy as zero at Ts and the separate salt's enthalpy as zero at its initial Ts. Under the constant-capacity model, the final solution-plus-pot enthalpy at temperature z is H+(C+S)*(z-Ts). Initial enthalpy just before addition at temperature x is C*(x-Ts). Instantaneous adiabatic mixing/dissolution therefore gives
  H+(C+S)*(z-Ts) = C*(x-Ts),
  z(x) = (C*x+S*Ts-H)/(C+S).
Equivalently, the signed mixing cooling energy is D(x)=S*(x-Ts)+H, and z-x=-D(x)/(C+S). Negative D means WARMING on mixing; no cooling premise is used.

For consistency, if the solid salt's constant sensible capacity is cs, isothermal dissolution at x costs H+(S-cs)*(x-Ts). This follows by subtracting the reactant capacity C+cs from product capacity C+S and integrating the enthalpy slope. Warming the solid from Ts to x costs cs*(x-Ts); the sum is H+S*(x-Ts). The Lean lemma reference_consistent_balance proves that the resulting balance (C+S)*(z-x)+cs*(x-Ts)+H+(S-cs)*(x-Ts)=0 is equivalent to the displayed z(x). Thus a positive solid heat capacity does not force S>=0. cs cancels and is not an independent parameter needed by the timing conclusion. These affine enthalpy laws are modeling choices; the algebraic consequence is proved. Temperature-dependent capacities would require integrating their actual functions.

Partanen & Partanen, Journal of Solution Chemistry 52, 1352-1385 (2023), Section 2, treats apparent enthalpy, dissolution and adiabatic temperature changes with explicit reference quantities. It provides general thermodynamic background only, not evidence for this pot's H or an exact constant-capacity law.
https://link.springer.com/article/10.1007/s10953-023-01322-y

Heating law and feasible timing domain

The retained approximation is constant heater-to-body power W and fixed room temperature A, with the SAME Newtonian heat loss k*(T-A) before and after addition, k>0. Hence net power is N(T)=W-k*(T-A). Salt does not change W or k at a common temperature in this approximation. The energy law is capacity*dT/dt=N(T), with capacity C before addition and C+S afterward. This model omits evaporation, radiation beyond the effective linear approximation, changes in heat transfer with concentration, heater feedback, material loss, stirring delay and dissolution delay. Mixing and complete dissolution are instantaneous with no heater pause. These are exposed approximations, not inferred facts about the apparatus.

B0 denotes the unsalted boiling temperature and B the fixed final mixture boiling temperature, both at the chosen pressure. F is a common SAFE liquid lower bound for both compositions over the applicable trajectories (choose it within the liquid region, not below either freezing boundary). L and U bound the interval of feasible addition temperatures. The final theorem requires:
  F <= 20 <= L <= U <= B0;
  F <= z(L) and z(U) <= B;
  N(U)>0 and N(B)>0;
  C>0, C+S>0, k>0.
The assumptions do not allow waiting through unsalted boiling. U=B0 permits adding at its onset, without dwelling there. Similarly z(U)=B permits the final endpoint to occur on mixing, without an intervening boiling/evaporation stage. If strict pre-boiling addition is required and U=B0 is excluded, a latest-endpoint optimum becomes an infimum approached from below, unless a smaller closed operational upper bound is selected.

The lemma feasible_trajectory derives that z is increasing (slope C/(C+S)>0) irrespective of S's sign. Therefore every x in [L,U] satisfies 20<=x<=B0 and F<=z(x)<=B, and both stages have positive net heating throughout. Unsalted water heats from 20 to x, and the mixture heats from z(x) to B, remaining liquid until each relevant endpoint. Solubility and absence of intermediate phase changes during the instantaneous idealized mixing are independent physical applicability requirements. If the full feasible set is nonempty under these affine constraints it is an interval; L and U should be its endpoints if optimizing over all feasible schedules. A deliberately narrower interval gives an optimum only over that interval. If even immediate mixing is too cold or too hot for these constraints, a conclusion at L=20 is not authorized.

Derived power change, elapsed times, and optimization

Applying the same N to the energy-conserving mixing temperature gives the proved power_change identity:
  N(z(x))-N(x) = k*[S*(x-Ts)+H]/(C+S) = k*D(x)/(C+S).
Since k>0 and C+S>0, net power increases exactly for cooling (D>0), decreases for warming (D<0), and is unchanged for D=0. There are no unrelated before/after powers. A net-power increase alone does not compare heating rates because capacity also changes.

With positive net power, integration of dt/dT=capacity/N(T) gives
  heatingTime(capacity,u,v) = capacity/k * log[N(u)/N(v)].
The Lean definition uses a difference of logarithms; the ratio is dimensionless. All numerical arguments use SI powers and temperatures in C. heating_time_derivative verifies the inverse first-law derivative, and stage_time_from_energy proves that any differentiable inverse elapsed-time curve with this derivative and zero initial value has exactly this endpoint time. This supplies an energy-law derivation and uniqueness, not just arithmetic for an assumed answer.

Total time to salted boiling for addition at x is
  t(x) = heatingTime(C,20,x) + heatingTime(C+S,z(x),B).
Waiting time BEFORE adding salt is heatingTime(C,20,x), not t(x). In particular x=20 gives zero waiting. The proof differentiates the full t, including z'(x)=C/(C+S), obtaining
  t'(x)=C/N(x)-C/N(z(x))
        = C*k*D(x)/[(C+S)*N(x)*N(z(x))].
Thus t' has exactly the sign of D(x), even when S<0. The Mean Value Theorem then proves global comparisons on the feasible interval, rather than just a stationary-point test.

The sole final theorem addition_timing_answer quantifies C,S,H,Ts,B,W,k,A,F,B0,L,U,x, under precisely the displayed feasibility and positivity inequalities and x in [L,U]. Its conclusion is the derived power-jump identity and these five conditional comparisons:

1. If S>=0 and D(L)>=0, then t(L)<=t(x): choose the earliest feasible temperature L.
2. If S>=0 and D(U)<=0, then t(U)<=t(x): choose the latest feasible temperature U.
3. If S>0 and r=Ts-H/S lies in [L,U], then t(r)<=t(x): choose that interior root or endpoint. For S>0 this is equivalently clamping r to [L,U], using cases 1 and 2 when r lies outside.
4. If S<=0, then min(t(L),t(U))<=t(x): compare the two explicit total-time formulas and choose the endpoint with the smaller value. An interior zero of D is a maximum when S<0, not the minimum. The proof handles either sign of D at x and compares along the appropriate subinterval.
5. If S=0 and H=0, then t(L)=t(x): all feasible schedules tie. For S=0,H>0 case 1 chooses earliest; for S=0,H<0 case 2 chooses latest.

These weak inequalities allow ties. They give no numerical time saving or unique optimum. In the distinct lossless limit k=0 all schedules tie in this constant-input calorimetric model, since the required energy C*(B-20)+S*(B-Ts)+H is timing independent. This limit is explanatory and is not a submitted theorem; the logarithmic definitions are used only for k>0.

Compact review packet

Supplied: one litre, 20 C start, pot on stove, unspecified salt and apparatus.
Additional choices: fixed soluble amount/composition/pressure/Ts; uniform pot-water body initially at 20; constant ORIGINAL capacity C>0 and final capacity C+S>0 with signed S; H referenced at Ts; affine enthalpies; shared constant-input Newton-loss law with k>0; instantaneous complete dissolution with no phase/material losses or delays. Feasible domain and positive-power endpoint constraints are explicit above. No empirical sign for S or H is assumed or inferred.
Necessary definitions in Lean: initialTemperature=20; netPower=N; mixedTemperature=z; heatingTime=integrated inverse first law; boilingTime=t. D and r are prose abbreviations only and are expanded in the final theorem. F,B0,L,U are direct scalar binders, not wrapper predicates. There are no additional axioms or sorry. Algebra, trajectory bounds, logarithmic integration and derivative signs are intermediate proved facts, not review assumptions.
Proved conclusion: exactly the power-change identity and five timing regimes listed above, with the stated domain. It is a conditional scientific answer; it does not establish that these approximations fit the actual pot or identify which regime applies. Measurements or literature for specified salt mass, composition, H at Ts and solution heat capacity across the temperature range, together with a calibrated heating curve and pressure, would select and test a regime. Salt temperature and feasible endpoints also matter. A numerical number of seconds requires C,W,k,A and the selected addition temperature; none are supplied. No human acceptance is claimed.

Lineage and checks

Cycle 1 left independent before/after powers and was rejected after formal verification; its files remain in history/cycle1. Cycle 2 used one shared heat-transfer law but assumed nonnegative additive S and insufficiently specified H's reference; its checked mathematical implication was rejected by the human for those scientific reasons. The submitted cycle-2 files and rejection are preserved in history/cycle2. This cycle retains the accepted heat-transfer approximation but corrects S, H and the feasible timing domain and replaces the old recommendation with complete conditional regimes. Prior checks and diagnostics were read, including the earlier independent-extraction failure and subsequent faithful extraction result. Raw traces remain unchanged.

Cycle-3 local logs are diagnostics/cycle3-compile-1.log (Lean not on PATH), cycle3-compile-2.log (missing explicit interval endpoint bound in an inequality tactic), and cycle3-compile-3.log (compiles). These are implementation corrections, not model changes. The required actual harness check is run against candidate.json after this report is written. Its raw trace and check directory are the authority for verification status. A successful Lean check establishes the implication from the displayed premises, not their physical truth or human approval.
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/Model.lean'"
}
shell output · exit 0
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/diagnostics/cycle3-check-1.txt /work/checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json /work/human-feedback.json'"
}
shell output · exit 0
{
 "file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean",
 "conclusions": [
  "addition_timing_answer"
 ],
 "lean_exit": 0,
 "ok": true,
 "compiles_alone": true,
 "faithful": {
  "addition_timing_answer": true
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
  "heatingTime",
  "boilingTime"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "addition_timing_answer": {
   "original_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00",
   "extracted_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00"
  }
 },
 "dependency_faithful": {
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "mixedTemperature": true,
  "netPower": true,
  "boilingTime": true,
  "heatingTime": true
 },
 "dependency_identities": {
  "initialTemperature": {
   "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
   "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
  },
  "initialTemperature._proof_1": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "mixedTemperature": {
   "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
   "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
  },
  "netPower": {
   "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
   "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
  },
  "boilingTime": {
   "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
   "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
  },
  "heatingTime": {
   "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
   "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "addition_timing_answer": "\u2200 (C S H Ts B W k A F B0 L U x : \u211d), 0 < C \u2192 0 < C + S \u2192 0 < k \u2192 F \u2264 initialTemperature \u2192 initialTemperature \u2264 L \u2192 L \u2264 U \u2192 U \u2264 B0 \u2192 F \u2264 mixedTemperature C S H Ts L \u2192 mixedTemperature C S H Ts U \u2264 B \u2192 0 < netPower W k A U \u2192 0 < netPower W k A B \u2192 x \u2208 Set.Icc L U \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 (0 \u2264 S \u2192 0 \u2264 S * (L - Ts) + H \u2192 boilingTime C S H Ts B W k A L \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 \u2264 S \u2192 S * (U - Ts) + H \u2264 0 \u2192 boilingTime C S H Ts B W k A U \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 < S \u2192 Ts - H / S \u2208 Set.Icc L U \u2192 boilingTime C S H Ts B W k A (Ts - H / S) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S \u2264 0 \u2192 min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S = 0 \u2192 H = 0 \u2192 boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x)"
 },
 "extracted_file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean",
 "errors": []
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T15:48:51.378080+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00",
        "extracted_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "mixedTemperature": true,
      "netPower": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B W k A F B0 L U x : \u211d), 0 < C \u2192 0 < C + S \u2192 0 < k \u2192 F \u2264 initialTemperature \u2192 initialTemperature \u2264 L \u2192 L \u2264 U \u2192 U \u2264 B0 \u2192 F \u2264 mixedTemperature C S H Ts L \u2192 mixedTemperature C S H Ts U \u2264 B \u2192 0 < netPower W k A U \u2192 0 < netPower W k A B \u2192 x \u2208 Set.Icc L U \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 (0 \u2264 S \u2192 0 \u2264 S * (L - Ts) + H \u2192 boilingTime C S H Ts B W k A L \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 \u2264 S \u2192 S * (U - Ts) + H \u2264 0 \u2192 boilingTime C S H Ts B W k A U \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 < S \u2192 Ts - H / S \u2208 Set.Icc L U \u2192 boilingTime C S H Ts B W k A (Ts - H / S) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S \u2264 0 \u2192 min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S = 0 \u2192 H = 0 \u2192 boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x)"
    },
    "extracted_file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:26:03.961421+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
{
  "decision": "reject",
  "binding": "f797b3f8a1d3e63d150060fcb98fab141b21fa029b778c95b9cbd3fb3191af67",
  "reason": "Human review of attempt 003: connect the conditional timing theorem to a justified physical case.\n\nHuman instruction, verbatim:\n\"We are not asking for numerical result, so that's OK. Just ask codex to connect his case with some assumptions about reality. Btw, what claude do we use? Sonnet?\"\n\nThe human accepts the shared constant-input Newtonian heating/loss approximation netPower(W,k,A,T) = W - k*(T-A), with the same law before and after salting. Keep the useful signed-capacity timing theorem and its energy-balance derivations.\n\nChoose and justify a concrete physical scenario consistent with the original one-litre, 20 C water task: specify the salt, a reasonable amount or concentration regime, initial salt/environmental conditions and relevant applicability assumptions. Use verified literature, physical relationships and explicit scenario assumptions to establish which of your conditional timing cases actually applies. In particular, establish the necessary heat-capacity-change and dissolution-energy signs/bounds with the correct enthalpy reference, rather than leaving S and H wholly unspecified or assuming the desired optimum. Material-property data or explicitly justified empirical models can be scientific premises; derive their consequences and the qualitative optimal timing in Lean. Derive the domain/positivity conditions you can from the chosen case and expose any remaining apparatus assumptions for human review. Do not allow waiting through unsalted boiling or an inadmissible mixing/phase state merely to obtain an optimum.\n\nA numerical time saving, a numerical heating duration, or a particular number of seconds is NOT required. A physically motivated case with a formally established recommendation such as earliest feasible addition is a sufficient target if your chosen physical assumptions imply it. Select and derive the appropriate recommendation independently; do not force that example recommendation as a premise. Preserve the existing original observations and provenance, avoid invented experiments and unverified recalled citations, and keep the assumptions/conclusions readable. You may request specific missing evidence through the existing protocol.\n\nNo other agent's model, parameter choices, numerical results or proof are supplied. This feedback requests revision, not full acceptance of attempt 003.\n",
  "time": "2026-11-17T22:50:26.998356+00:00",
  "verification_verdict": "proved"
}
web_search input
{
  "query": "sodium chloride aqueous apparent molar heat capacity enthalpy solution 273 373 temperature 0.1 mol kg Partanen 2025",
  "action": {
    "type": "search",
    "query": "sodium chloride aqueous apparent molar heat capacity enthalpy solution 273 373 temperature 0.1 mol kg Partanen 2025"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "acris.aalto.fi",
      "ref_id": "turn0search12",
      "snippet": "# Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2—The Quantities",
      "title": "Journal of Solution Chemistry (2025) 54:286–316",
      "url": "https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf"
    },
    {
      "type": "text_result",
      "domain": "aaltodoc.aalto.fi",
      "ref_id": "turn0search13",
      "snippet": "Journal of Solution Chemistry (2025) 54:286–316 Table 11 Recommended value of the relative apparent molar heat capacity (∆Capp, defined in footnote a) of salt (symbol",
      "title": "This is an electronic reprint of the original article.",
      "url": "https://aaltodoc.aalto.fi/server/api/core/bitstreams/8a8efdcb-a5ee-4fec-8d50-949aae744598/content"
    },
    {
      "type": "text_result",
      "domain": "acris.aalto.fi",
      "ref_id": "turn0search14",
      "snippet": "** Recommended value for the relative apparent molar enthalpy (\\(\\Delta H_{\\mathrm{app}}\\)) of salt (symbol 2) in dilute aqueous NaCl solutions at temperatures from 358.15 to",
      "title": "<table id=\"e1\">",
      "url": "https://acris.aalto.fi/ws/portalfiles/portal/126147523/CHEM_Partanen_L_and_Partanen_J_Thermodynamically_Traceable_2023_J_Solution_Chem.pdf"
    },
    {
      "type": "text_result",
      "domain": "link.springer.com",
      "ref_id": "turn0search0",
      "snippet": "# Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associated with the Partial Molar Heat Capacity",
      "url": "https://link.springer.com/article/10.1007/s10953-024-01412-5"
    },
    {
      "type": "text_result",
      "domain": "doi.org",
      "ref_id": "turn0search1",
      "snippet": "# Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities Associated with the Partial Molar Enthalpy",
      "url": "https://doi.org/10.1007/s10953-023-01322-y"
    },
    {
      "type": "text_result",
      "domain": "research.aalto.fi",
      "ref_id": "turn0search2",
      "snippet": "# Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associated with the Partial Molar Heat Capacity",
      "url": "https://research.aalto.fi/en/publications/thermodynamically-traceable-calorimetric-results-for-aqueous-sodi-2/"
    },
    {
      "type": "text_result",
      "domain": "link.springer.com",
      "ref_id": "turn0search3",
      "snippet": "# Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities Associated with the Partial Molar Enthalpy",
      "url": "https://link.springer.com/article/10.1007/s10953-023-01322-y"
    },
    {
      "type": "text_result",
      "domain": "research.aalto.fi",
      "ref_id": "turn0search4",
      "snippet": "AU - Partanen, Lauri J. ... Solution Chem. 52: 1352 − 1385 (2023)), we presented a traceable and transparent three-parameter model for thermodynamic activity and",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associated with the Partial Molar Heat Capacity",
      "url": "https://research.aalto.fi/fi/publications/thermodynamically-traceable-calorimetric-results-for-aqueous-sodi-2/"
    },
    {
      "type": "text_result",
      "domain": "www.scribd.com",
      "ref_id": "turn0search5",
      "snippet": "mo = 1 mol⋅kg−1 ... unit is J⋅K–1⋅mol−1, and it is given at temperature T expressed as (T–273.15 K)/K ... 312 Journal of Solution Chemistry",
      "title": "Heat Capacity of Aqueous NaCl Solutions | PDF | Heat Capacity | Heat",
      "url": "https://www.scribd.com/document/938452961/Thermodynamically-Traceable-Calorimetric-Results-for-Aqueous-Sodium-Chloride-Solutions-From-T-273-15-to-373-15-K-Up-to-the-Saturated-Solutions-Part-2"
    },
    {
      "type": "text_result",
      "domain": "www.researchgate.net",
      "ref_id": "turn0search6",
      "snippet": "for the relative apparent molar ... 358.15 to 373.15 K as a function ... is the partial molar enthalpy at infinite dilution ... a m",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities Associated with the Partial Molar Enthalpy",
      "url": "https://www.researchgate.net/publication/373829145_Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_27315_to_37315_K_up_to_the_Saturated_Solutions_Part_1-The_Quantities_Associated_with_the_Partial_Molar_Ent"
    },
    {
      "type": "text_result",
      "domain": "doi.org",
      "ref_id": "turn0search7",
      "snippet": "Table 3 Parameter values for the dependence of the relative apparent molar heat capacity on the molality, Eq. 20 (see also Table 1), for NaCl",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associated with the Partial Molar Heat Capacity",
      "url": "https://doi.org/10.1007/s10953-024-01412-5?urlappend=%3Futm_source%3Dresearchgate.net%26utm_medium%3Darticle"
    },
    {
      "type": "text_result",
      "domain": "www.finna.fi",
      "ref_id": "turn0search8",
      "snippet": "In previous articles (Partanen and Partanen in J. ... Solution Chem. 52: 1352 − 1385 (2023)), we presented a traceable and transparent three-parameter model for",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associate... | Aalto-yliopisto - Aaltodoc | Finna.fi",
      "url": "https://www.finna.fi/Record/aaltodoc.123456789_135954"
    },
    {
      "type": "text_result",
      "domain": "tiedejatutkimus.fi",
      "ref_id": "turn0search9",
      "snippet": "# Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The",
      "title": "RESEARCH.FI",
      "url": "https://tiedejatutkimus.fi/fi/results/publication/02209032YJ"
    },
    {
      "type": "text_result",
      "domain": "research.aalto.fi",
      "ref_id": "turn0search10",
      "snippet": "* Temperature dependence ... * CHEM_Partanen_L_and_Partanen_J_Thermodynamically_Traceable_2023_J_Solution_Chem Final published version, 1.31 MB Licence: CC BY ... Thermodynamically Traceable Calorimet",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 1—The Quantities Associated with the Partial Molar Enthalpy",
      "url": "https://research.aalto.fi/en/publications/thermodynamically-traceable-calorimetric-results-for-aqueous-sodi/"
    },
    {
      "type": "text_result",
      "domain": "www.finna.fi",
      "ref_id": "turn0search11",
      "snippet": "In previous articles (Partanen and Partanen in J. ... Solution Chem. 52: 1352 − 1385 (2023)), we presented a traceable and transparent three-parameter model for",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2 —The Quantities Associate... | Aalto University Learning Centre | Finna.fi",
      "url": "https://www.finna.fi/Record/aaltodoc.123456789_135954?lng=en-gb"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search15",
      "snippet": "Sodium chloride (data page) ## Density data of aqueous solutions ... 0.5 | −0.3 | 1.0018 | 1.3339 | 1.011 ... Note: ρ is density,",
      "title": "Sodium chloride (data page)",
      "url": "https://en.wikipedia.org/wiki/Sodium_chloride_%28data_page%29"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search16",
      "snippet": "The enthalpy of solution is most often expressed in kJ/mol at constant temperature. ... The enthalpy change in this process, normalized by the mole number",
      "title": "Enthalpy change of solution",
      "url": "https://en.wikipedia.org/wiki/Enthalpy_change_of_solution"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search17",
      "snippet": "Enthalpy change ... at 273.15 K, 1 bar, Δ_{fus}S | 22.0 J/(mol·K) ... vaporization at 373.15 K, Δ_{vap}H | 40.68 kJ/mol ... Molal boiling point",
      "title": "Water (data page)",
      "url": "https://en.wikipedia.org/wiki/Water_%28data_page%29"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search18",
      "snippet": "The molar heat capacity of a chemical substance is the amount of energy that must be added, in the form of heat, to one mole",
      "title": "Molar heat capacity",
      "url": "https://en.wikipedia.org/wiki/Molar_heat_capacity"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search19",
      "snippet": "J⋅g^{−1}⋅K^{−1} | Molar heat capacity, ... mol-atom^{−1} ... 0 °C (273.15 K)) | gas | 1.0035 | 29.070 | 20.764 | 0.001297 | ... Water",
      "title": "Table of specific heat capacities",
      "url": "https://en.wikipedia.org/wiki/Table_of_specific_heat_capacities"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search20",
      "snippet": "The thermal conductivity of sodium chloride as a function of temperature has a maximum of 2.03 W/(cm K) at 8 K (−265.15 °C; −445.27 °F)",
      "title": "Sodium chloride",
      "url": "https://en.wikipedia.org/wiki/Sodium_chloride"
    },
    {
      "type": "text_result",
      "domain": "www.reddit.com",
      "ref_id": "turn0reddit21",
      "snippet": "traslation: two solutions with initial temperature of 24.69 °C, are mixed inside a cup calorimeter C=105.5 J/°C): 200 mL of AgNO3 solution 0.1 M and",
      "title": "Any idea on how to solve it?",
      "url": "https://www.reddit.com/r/chemhelp/comments/17hnzee"
    },
    {
      "type": "text_result",
      "domain": "arxiv.org",
      "ref_id": "turn0academia22",
      "snippet": "Title: The CPA Equation of State and an Activity Coefficient Model for Accurate Molar Enthalpy Calculations of Mixtures with Carbon Dioxide and Water/Brine ... In",
      "title": "The CPA Equation of State and an Activity Coefficient Model for Accurate Molar Enthalpy Calculations of Mixtures with Carbon Dioxide and Water/Brine",
      "url": "https://arxiv.org/abs/1504.05123"
    },
    {
      "type": "text_result",
      "domain": "www.reddit.com",
      "ref_id": "turn0reddit23",
      "snippet": "It’s not great, but you might be able to find data for solutions of sodium chloride, calcium chloride, and maybe magnesium chloride. ... The solution",
      "title": "Do ions have Heat Capacity ?",
      "url": "https://www.reddit.com/r/ChemicalEngineering/comments/17x8uh9"
    }
  ]
}
assistant
The previous proof passed the formal check; the human rejected it because no material-property evidence selected a physical timing case. I found primary thermodynamic studies of aqueous NaCl, but their relative apparent quantities need reference-state conversions before they can supply the model’s heat-capacity change and dissolution energy. I’ll request those data for a concrete household-scale salt dose before making a recommendation.
shell input
{
  "command": "/usr/bin/bash -lc 'mkdir -p /work/history/cycle3 /work/evidence/cycle4'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'cp /work/Model.lean /work/report.txt /work/candidate.json /work/human-feedback.json /work/history/cycle3/'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\np=Path('/work/evidence/cycle4/research-notes.txt')\np.write_text('''Cycle 4: evidence request preparation, 2026-11-17 UTC.\nReviewed Model.lean, report.txt, candidate.json, human-feedback.json, cycle3-check-1.txt and stored verdicts. Cycle 3 compilation/extraction succeeded (8ce875bbeedf40f384474d008e4dfa66); human rejected physical underdetermination, not the signed-capacity algebra. Older f49ea96bd5de45babf8f3c699ba15e09 extraction failure remains preserved. No new candidate or check success is claimed.\n\nProspective concrete case, introduced by researcher, not user data: pure dry crystalline NaCl, 10 g, initially 20 C, into the original litre of initially 20 C water; ambient 20 C and near atmospheric pressure. Water mass to be obtained using density rather than silently equating 1 litre with 1 kg. Fixed salt amount across schedules, full dissolution, well mixed, negligible evaporation; same accepted heater/loss law. Room-temperature salt retained while water heats. No material signs or conclusion selected yet.\n\nVerified bibliographic search results from web search in this run:\nPartanen & Partanen, Journal of Solution Chemistry 54 (2025), 286-316, DOI 10.1007/s10953-024-01412-5, published 20 October 2024. Title: Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2—The Quantities Associated with the Partial Molar Heat Capacity.\nOfficial page https://link.springer.com/article/10.1007/s10953-024-01412-5\nInstitutional copy https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf\nSearch excerpt explicitly distinguishes relative apparent heat capacity Delta C_app = C_app - C_infinite; its tables cannot be treated as absolute C_app.\nPartanen & Partanen, Journal of Solution Chemistry 52 (2023), 1352-1385, DOI 10.1007/s10953-023-01322-y. Part 1—The Quantities Associated with the Partial Molar Enthalpy.\nOfficial page https://link.springer.com/article/10.1007/s10953-023-01322-y\nInstitutional copy https://acris.aalto.fi/ws/portalfiles/portal/126147523/CHEM_Partanen_L_and_Partanen_J_Thermodynamically_Traceable_2023_J_Solution_Chem.pdf\nSearch excerpts show relative apparent enthalpy tables, not automatically integral solid-to-solution dissolution enthalpy. No numerical material values have been imported as evidence.\n\nPending request seeks absolute solution-minus-water capacity and integral dissolution enthalpy with references and validity range. It is literature/calculation evidence, not a physical experiment. No response yet; no response ID to incorporate. Preserve the current candidate unchanged pending response. Do not claim a new formal result or human approval.\n''')\nPY\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python /harness/src/vcs_protocol.py tool request --kind literature --question 'For the revision of the salt-addition timing task, please supply verified primary-source material-property evidence for this explicit scenario: 10 g of pure dry crystalline NaCl initially at 20 degrees C, added to the original 1 litre of initially 20 C liquid water, near atmospheric pressure, with ambient and stored salt held at 20 C. These are researcher scenario choices, not new observations. Needed: (1) water density at 20 C to convert the supplied volume to solvent mass and hence molality; (2) absolute apparent molar heat capacity C_app(T,m) = [C_solution(T)-C_original_water(T)]/n, or equivalent solution specific heat and water specific heat data, for approximately 0.17 mol/kg across roughly 19 to 101 C (at least 20, 60 and 100 C, with uncertainty/validity limits); (3) integral isothermal enthalpy of dissolving the solid NaCl to that final concentration at 20 C, positive for endothermic dissolution, in J/mol, with uncertainty and an explicit reference; (4) enough solubility, liquid phase and boiling-point information to justify feasible liquid trajectories. Please distinguish absolute C_app from relative apparent capacity C_app-C_infinite, and integral solid dissolution enthalpy from relative apparent enthalpy. If conversions are required, supply their reference values and physical relationships. Candidate primary sources found this cycle are Partanen and Partanen, DOI 10.1007/s10953-024-01412-5 (heat capacities) and 10.1007/s10953-023-01322-y (enthalpies); institutional PDFs are recorded in /work/evidence/cycle4/research-notes.txt. Data from other verified primary sources are welcome. Please do not prescribe the timing optimum or choose capacity/enthalpy values to force one. The retained model is lumped constant-input heating with the same Newtonian loss law before/after salting, and positive total heat capacities. We will use the evidence to justify an explicitly labeled effective constant-capacity approximation if defensible, derive its signs/bounds and timing regime in Lean, and disclose remaining apparatus conditions; if material temperature variation defeats that reduction, please flag this instead of treating a point value as a uniform bound. This is a literature request, not a request to invent a physical measurement.'\""
}
shell output · exit 0
{"id": "f7c987a52391410bb035542305825b3f", "kind": "literature", "question": "For the revision of the salt-addition timing task, please supply verified primary-source material-property evidence for this explicit scenario: 10 g of pure dry crystalline NaCl initially at 20 degrees C, added to the original 1 litre of initially 20 C liquid water, near atmospheric pressure, with ambient and stored salt held at 20 C. These are researcher scenario choices, not new observations. Needed: (1) water density at 20 C to convert the supplied volume to solvent mass and hence molality; (2) absolute apparent molar heat capacity C_app(T,m) = [C_solution(T)-C_original_water(T)]/n, or equivalent solution specific heat and water specific heat data, for approximately 0.17 mol/kg across roughly 19 to 101 C (at least 20, 60 and 100 C, with uncertainty/validity limits); (3) integral isothermal enthalpy of dissolving the solid NaCl to that final concentration at 20 C, positive for endothermic dissolution, in J/mol, with uncertainty and an explicit reference; (4) enough solubility, liquid phase and boiling-point information to justify feasible liquid trajectories. Please distinguish absolute C_app from relative apparent capacity C_app-C_infinite, and integral solid dissolution enthalpy from relative apparent enthalpy. If conversions are required, supply their reference values and physical relationships. Candidate primary sources found this cycle are Partanen and Partanen, DOI 10.1007/s10953-024-01412-5 (heat capacities) and 10.1007/s10953-023-01322-y (enthalpies); institutional PDFs are recorded in /work/evidence/cycle4/research-notes.txt. Data from other verified primary sources are welcome. Please do not prescribe the timing optimum or choose capacity/enthalpy values to force one. The retained model is lumped constant-input heating with the same Newtonian loss law before/after salting, and positive total heat capacities. We will use the evidence to justify an explicitly labeled effective constant-capacity approximation if defensible, derive its signs/bounds and timing regime in Lean, and disclose remaining apparatus conditions; if material temperature variation defeats that reduction, please flag this instead of treating a point value as a uniform bound. This is a literature request, not a request to invent a physical measurement.", "time": "2026-11-17T22:52:12.953880+00:00"}
Stop this cycle. A human must supply the actual response before you resume.
assistant
Requested verified literature data for a concrete case: **10 g of NaCl at 20°C added to the original litre of water**. The request covers heat-capacity changes, reference-consistent dissolution enthalpy, and liquid-phase limits needed to select a timing recommendation.

Request ID: `f7c987a52391410bb035542305825b3f`.

Stopped pending the operator’s actual response. Prior proofs and feedback are preserved; no new result or approval is claimed.

Produced code

checks/19e916da3a2f417381acb479d8151af9/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring

Round 5

Messages

user
This supplies material-property literature for YOUR proposed 10 g crystalline NaCl / original 1 L water scenario. It supplies no new physical measurements, fitted heating curve, other agent's work, or timing recommendation. The original human instruction requires a physically supported qualitative timing result; numerical heating duration or time saving is not required.

The source bundle is /work/inputs/material-evidence-001/. It contains original PDFs, text extractions and sources.json with URLs, byte counts and SHA256 hashes. Archer's scanned PDF has a separately labelled OCR transcription; verify its signs, coefficients, exponents and tables against the PDF. OCR is not authoritative data. You may consult the original sources online as well.

1. Water density and pure-water thermal properties.
NIST, GLP 10, Water Density Calculations, in the supplied nist-water-density.pdf: GLP10 printed pages 4-5 (the density section, not unrelated procedures in the same compilation). It gives the Tanaka et al. (Metrologia 38, 301-309, 2001) equation valid at 0-40 C, air-saturation correction, and formulation uncertainty. Its example table at 20 C gives air-free density 0.99820675 g/cm3, or 998.20675 kg/m3. Air-saturated density is 0.99820426 g/cm3. One litre therefore corresponds to about 0.9982 kg under those reference conditions. water-density-evaluation.json records the operator's arithmetic evaluation of equations 1-3, separately from the published data. Its approximately 0.00083 kg/m3 formula uncertainty does not establish the task's actual volume, temperature, purity or pressure uncertainty.
Source: https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf
IAPWS R6-95(2018), iapws95-2018.pdf, supplies the pure-water equation of state, heat-capacity relationships, vapor-liquid equilibrium and uncertainty guidance. Use it for applicable liquid states and pure-water boiling at your chosen pressure, not to describe stable liquid water above its own boiling temperature at that pressure.
Source: https://iapws.org/technical-guidance/release/IAPWS-95 (current PDF: https://iapws.org/technical-guidance/release/IAPWS-95.download).

2. NaCl heat capacity and reference-state conversion.
Partanen & Partanen, Journal of Solution Chemistry 54, 286-316 (2025), DOI 10.1007/s10953-024-01412-5: partanen-2025-heat-capacity.pdf/.txt. Section 2.2, equations 9-11, distinguish C_app = (C_solution - C_original_water)/n from Delta C_app = C_app - C_infinite. Equations 18-20 and their parameter tables provide temperature/molality dependence; section 3.2 and table 5 identify experimental datasets and their coverage. The main model covers 273.15-373.15 K, not an automatically certified 101 C extension.
Table 2 (journal page 293, PDF page 9) gives absolute apparent heat capacities at 25 C: -71.0 J/(K mol) at m=0.15 mol/kg and -68.7 at m=0.20, using C_infinite=-84.0. These are neighboring composition reference points, not your exact m or a bound at all temperatures. IMPORTANT: equation 22 and table 5 use a different temperature-dependent infinite-dilution baseline for comparisons, yielding -58 at 25 C. Do not mix that convention with table 2's -84 baseline without assessing the difference. Regression confidence intervals for relative values do not by themselves cover uncertainty of the absolute baseline.
Primary source: https://doi.org/10.1007/s10953-024-01412-5 ; institutional PDF URL in sources.json.

3. Integral dissolution enthalpy.
Partanen & Partanen, Journal of Solution Chemistry 52, 1352-1385 (2023), DOI 10.1007/s10953-023-01322-y: partanen-2023-enthalpy.pdf/.txt. Section 2.2, especially equations 5-10, specifies enthalpy/reference conventions; equations 13-20 and tables 2-4 give the finite-concentration relative contribution. Table 8 (journal page 1368, PDF page 18) reports standard molar solid dissolution enthalpy at infinite dilution: +4481 J/mol at the actual 19.97 C point and +3824 J/mol at 25.00 C. Its footnotes explicitly distinguish solution enthalpy from a different salt enthalpy convention. Do not label the 25 C value as a 20 C finite-concentration measurement. For a consistent convention, finite-concentration isothermal solid dissolution enthalpy is the infinite-dilution solid dissolution enthalpy plus Delta H_app at that SAME temperature and composition. Use the source's equations to calculate the concentration correction and state interpolation/reference uncertainty. Table 8 alone provides no newly certified confidence bound for your case.
Primary source: https://doi.org/10.1007/s10953-023-01322-y ; institutional PDF URL in sources.json.

4. Independent unified thermodynamic and phase-equilibrium reference.
Donald G. Archer, Thermodynamic Properties of the NaCl + H2O System. II. Thermodynamic Properties of NaCl(aq), NaCl.2H2O(cr), and Phase Equilibria, J. Phys. Chem. Ref. Data 21, 793 (1992), DOI 10.1063/1.555915: archer-1992-nacl-water.pdf and labelled -ocr.txt. Section 4.1 (journal pages 797-801) gives the equation set and coefficients; sections 4.2.4-4.2.5 (812-815) assess dissolution enthalpy and heat-capacity measurements and systematic errors. Section 5 (815-818) treats solubility/phase equilibria and water activity; these support checking liquid-state, complete dissolution, freezing and boiling constraints. Table 8 (819) gives standard-state salt thermal reference quantities, not finite-concentration dissolution heat. The study describes data roughly 250-600 K with pressure-dependent validity; apply its actual phase/domain restrictions. It is an independent source for evaluating an absolute, internally consistent property set, rather than silently combining incompatible reference tables.
Source: https://www.nist.gov/system/files/documents/srd/jpcrd440.pdf

Additional reference if solid-salt sensible heat/reference conversion is needed: NIST-JANAF NaCl(cr,l), https://janaf.nist.gov/tables/Cl-055.html , gives crystalline Cp=50.509 J/(K mol) at 298.15 K. NIST Chemistry WebBook https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2 lists molecular weight 58.443 and a solid Shomate correlation with stated range 298-1073 K; it is not validated at 293.15 K merely because it can be evaluated there. Copies of those source pages are in the bundle.

No operator-certified absolute C_app table at exactly 20, 60 and 100 C with a uniform 19-101 C uncertainty bound is asserted here. The original models, data references, competing baselines and their limits are supplied so you can derive or justify the needed material-property assumptions transparently. Evaluate a consistent supported model, distinguish calculated/interpolated properties from measured points, and identify any remaining empirical bound or extrapolation as a model assumption for review. In particular, a point estimate is not a uniform-temperature bound and an effective constant capacity needs its own justification. Preserve the selected amount and do not tune inputs to force a preferred optimum.
assistant
I’ll review the previous proof, check diagnostics, and supplied material evidence, then use them to revise the physical case and timing conclusion.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work'"
}
shell output · exit 0
total 88
drwxrwxr-x 8 1001 1001  4096 Nov 17 23:34 .
drwxr-xr-x 1 root root  4096 Nov 17 23:35 ..
-rw-r--r-- 1 1001 1001 14783 Nov 17 15:48 Model.lean
-rw-r--r-- 1 1001 1001  2597 Nov 17 15:48 candidate.json
drwxr-xr-x 7 1001 1001  4096 Nov 17 15:48 checks
drwxr-xr-x 2 1001 1001  4096 Nov 17 15:48 diagnostics
drwxr-xr-x 3 1001 1001  4096 Nov 17 22:52 evidence
drwxr-xr-x 5 1001 1001  4096 Nov 17 22:52 history
-rw------- 1 1001 1001  2572 Nov 17 22:50 human-feedback.json
drwxrwxr-x 3 1001 1001  4096 Nov 17 23:34 inputs
-rw------- 1 1001 1001  9249 Nov 17 15:50 last-review-packet.json
-rw-r--r-- 1 1001 1001   456 Nov 17 14:15 lean-env.sh
-rw-r--r-- 1 1001 1001 13467 Nov 17 15:48 report.txt
drwxr-xr-x 2 1001 1001  4096 Nov 17 23:34 requests
shell input
{
  "command": "/usr/bin/bash -lc 'rg --files /work | head -70'"
}
shell output · exit 0
/usr/bin/bash: line 1: rg: command not found
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/Model.lean'"
}
shell output · exit 0
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
shell input
{
  "command": "/usr/bin/bash -lc 'find /work/history /work/checks /work/inputs/material-evidence-001 -maxdepth 2 -type f'"
}
shell output · exit 0
/work/history/cycle1/report.txt
/work/history/cycle1/human-feedback.json
/work/history/cycle1/Model.lean
/work/history/cycle1/candidate.json
/work/history/cycle2/report.txt
/work/history/cycle2/human-feedback.json
/work/history/cycle2/Model.lean
/work/history/cycle2/candidate.json
/work/history/cycle3/report.txt
/work/history/cycle3/human-feedback.json
/work/history/cycle3/Model.lean
/work/history/cycle3/candidate.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-report.txt
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-candidate.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/lean.log
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-report.txt
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-candidate.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/lean.log
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-report.txt
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-candidate.json
/work/checks/19e916da3a2f417381acb479d8151af9/lean.log
/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.json
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/verdict.json
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-report.txt
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-candidate.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-report.txt
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-candidate.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/lean.log
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean
/work/inputs/material-evidence-001/archer-preview-01.png
/work/inputs/material-evidence-001/archer-1992-nacl-water.pdf
/work/inputs/material-evidence-001/water-density-evaluation.json
/work/inputs/material-evidence-001/nist-webbook-nacl.html
/work/inputs/material-evidence-001/sources.json
/work/inputs/material-evidence-001/partanen-2023-enthalpy.pdf
/work/inputs/material-evidence-001/nist-webbook-nacl.txt
/work/inputs/material-evidence-001/nist-water-density.pdf
/work/inputs/material-evidence-001/iapws95-2018.pdf
/work/inputs/material-evidence-001/iapws95-2018.txt
/work/inputs/material-evidence-001/archer-1992-nacl-water.txt
/work/inputs/material-evidence-001/nist-janaf-nacl-solid.html
/work/inputs/material-evidence-001/nist-water-density.txt
/work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt
/work/inputs/material-evidence-001/archer-preview-02.png
/work/inputs/material-evidence-001/partanen-2025-heat-capacity.pdf
/work/inputs/material-evidence-001/partanen-2023-enthalpy.txt
/work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt
/work/inputs/material-evidence-001/nist-janaf-nacl-solid.txt
shell input
{
  "command": "/usr/bin/bash -lc \"cat /work/evidence/cycle4/research-notes.txt; cat /work/candidate.json; cat /work/checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json; sed -n '180,420p' /work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-023-01322-y

https://doi.org/10.1007/s10953-024-01412-5

Cycle 4: evidence request preparation, 2026-11-17 UTC.
Reviewed Model.lean, report.txt, candidate.json, human-feedback.json, cycle3-check-1.txt and stored verdicts. Cycle 3 compilation/extraction succeeded (8ce875bbeedf40f384474d008e4dfa66); human rejected physical underdetermination, not the signed-capacity algebra. Older f49ea96bd5de45babf8f3c699ba15e09 extraction failure remains preserved. No new candidate or check success is claimed.

Prospective concrete case, introduced by researcher, not user data: pure dry crystalline NaCl, 10 g, initially 20 C, into the original litre of initially 20 C water; ambient 20 C and near atmospheric pressure. Water mass to be obtained using density rather than silently equating 1 litre with 1 kg. Fixed salt amount across schedules, full dissolution, well mixed, negligible evaporation; same accepted heater/loss law. Room-temperature salt retained while water heats. No material signs or conclusion selected yet.

Verified bibliographic search results from web search in this run:
Partanen & Partanen, Journal of Solution Chemistry 54 (2025), 286-316, DOI 10.1007/s10953-024-01412-5, published 20 October 2024. Title: Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions from T = (273.15 to 373.15) K up to the Saturated Solutions: Part 2—The Quantities Associated with the Partial Molar Heat Capacity.
Official page https://link.springer.com/article/10.1007/s10953-024-01412-5
Institutional copy https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf
Search excerpt explicitly distinguishes relative apparent heat capacity Delta C_app = C_app - C_infinite; its tables cannot be treated as absolute C_app.
Partanen & Partanen, Journal of Solution Chemistry 52 (2023), 1352-1385, DOI 10.1007/s10953-023-01322-y. Part 1—The Quantities Associated with the Partial Molar Enthalpy.
Official page https://link.springer.com/article/10.1007/s10953-023-01322-y
Institutional copy https://acris.aalto.fi/ws/portalfiles/portal/126147523/CHEM_Partanen_L_and_Partanen_J_Thermodynamically_Traceable_2023_J_Solution_Chem.pdf
Search excerpts show relative apparent enthalpy tables, not automatically integral solid-to-solution dissolution enthalpy. No numerical material values have been imported as evidence.

Pending request seeks absolute solution-minus-water capacity and integral dissolution enthalpy with references and validity range. It is literature/calculation evidence, not a physical experiment. No response yet; no response ID to incorporate. Preserve the current candidate unchanged pending response. Do not claim a new formal result or human approval.
{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "addition_timing_answer"
  },
  "user_facts": [
    "One litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.",
    "Salt will be added; salt quantity, pot, heater and room conditions are otherwise unspecified."
  ],
  "model_choices": [
    "Deterministic lumped constant-capacity model with original water-plus-pot C>0 and final solution-plus-pot C+S>0; S is the signed solution-minus-water capacity difference, never assumed nonnegative. Pot initially equilibrated at 20 C.",
    "Fixed soluble salt amount, final composition, pressure, salt temperature Ts, unsalted boiling B0 and solution boiling B across schedules. H is integral isothermal dissolution enthalpy at Ts (either sign); affine enthalpies imply dissolution enthalpy H+(S-cs)*(T-Ts) at T for solid salt capacity cs, not a constant dissolution heat at all temperatures.",
    "Instantaneous adiabatic mixing and complete dissolution; no heating interruption, evaporation, phase changes before endpoint or material loss. Constant capacities and the liquid/soluble regime are conditional approximations, not inferred material properties.",
    "Shared before/after net power N(T)=W-k*(T-A), constant heater input and room temperature, k>0; no independent salinity dependence of heat transfer. Heating obeys capacity*dT/dt=N(T).",
    "Compare a nonempty feasible interval [L,U] with F<=20<=L<=U<=B0, F<=z(L), z(U)<=B, N(U)>0 and N(B)>0. F is a safe common liquid lower bound; these constraints enforce liquid heating stages. Endpoint onsets of boiling are permitted without dwelling. Use full feasible interval for a global physical scheduling optimum."
  ],
  "sources": [
    "https://link.springer.com/article/10.1007/s10953-024-01412-5",
    "https://link.springer.com/article/10.1007/s10953-023-01322-y"
  ],
  "incorporated_inputs": [],
  "proof_scope": "Derives reference-consistent mixing balance with signed heat-capacity change, the net-power jump from the shared heater/loss law, stage-time integration and uniqueness from the inverse first law, and the derivative of full boiling time. Proves global earliest/latest/interior-root regimes for S>=0 and endpoint minimum for S<=0, including the S=H=0 tie, on an explicitly feasible liquid interval. No parameter values or material-property signs are inferred from absent observations; physical validity and regime selection remain for human review. No additional axioms, sorry, external responses, experiments or human approval are claimed."
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:26:03.961421+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '420,640p' /work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt; sed -n '760,960p' /work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-024-01412-5
assistant
The literature confirms that the heat-capacity change needs care: dilute NaCl can reduce the solution’s total heat capacity, and its apparent molar heat capacity varies substantially with temperature. I’m checking a consistent enthalpy reference before using those properties to choose a timing regime.
shell input
{
  "command": "/usr/bin/bash -lc \"grep -n -E 'Table 8|4481|3824|Table 5|infinite|quadratic|linear' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt | head -60; cat /work/inputs/material-evidence-001/sources.json\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-023-01322-y

{
  "retrieved_at": "2026-11-17T23:29:22.974500+00:00",
  "kind": "Primary-source material-property literature, not physical measurements or a timing recommendation",
  "sources": [
    {
      "file": "partanen-2025-heat-capacity.pdf",
      "source_url": "https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf",
      "bytes": 1504497,
      "sha256": "7e35e7a61dc456c001e0ef2f33786b34b60d645da7a09fa0ab70869de606a6f9",
      "text_bytes": 129401,
      "extraction": "pdftotext -layout; whitespace/equation layout may need original PDF verification"
    },
    {
      "file": "partanen-2023-enthalpy.pdf",
      "source_url": "https://acris.aalto.fi/ws/portalfiles/portal/126147523/CHEM_Partanen_L_and_Partanen_J_Thermodynamically_Traceable_2023_J_Solution_Chem.pdf",
      "bytes": 1592251,
      "sha256": "5634838e68bef08c086d2a291d6a6764e0603942c37fef8551db3d7093070130",
      "text_bytes": 149390,
      "extraction": "pdftotext -layout; whitespace/equation layout may need original PDF verification"
    },
    {
      "file": "archer-1992-nacl-water.pdf",
      "source_url": "https://www.nist.gov/system/files/documents/srd/jpcrd440.pdf",
      "bytes": 3083239,
      "sha256": "54591c01d4a1f2dd39ece89fe777b3e25ef91e245592d793886d8712eac5f1d2",
      "text_bytes": 37,
      "extraction": "Scanned PDF: text extraction empty; inspect original pages/OCR"
    },
    {
      "file": "nist-water-density.pdf",
      "source_url": "https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf",
      "bytes": 1801418,
      "sha256": "95a4699e41a3fcc4f327a4e5a28e1b91c05b4dbfd64c1c3ac2e2104d5095306d",
      "text_bytes": 343576,
      "extraction": "pdftotext -layout; whitespace/equation layout may need original PDF verification"
    },
    {
      "file": "iapws95-2018.pdf",
      "source_url": "https://iapws.org/technical-guidance/release/IAPWS-95.download",
      "bytes": 380240,
      "sha256": "512879217b94f4d0741c88cab743d41098268914d538d73e680a736cb1c3aad7",
      "text_bytes": 78906,
      "extraction": "pdftotext -layout; whitespace/equation layout may need original PDF verification"
    },
    {
      "file": "nist-janaf-nacl-solid.html",
      "source_url": "https://janaf.nist.gov/tables/Cl-055.html",
      "retrieved_url": "https://janaf.nist.gov/tables/Cl-055.html",
      "bytes": 11408,
      "sha256": "828810708e7d79d8387d78ff60b31d7ea5713478ca83be86545716bbc479949c",
      "text_file": "nist-janaf-nacl-solid.txt",
      "text_bytes": 2604
    },
    {
      "file": "nist-webbook-nacl.html",
      "source_url": "https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2",
      "retrieved_url": "https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2",
      "bytes": 27992,
      "sha256": "e83320ebbf3b6414fd8c4690352144ba0039c0b1f3ae019d2e009e73bef6dcaf",
      "text_file": "nist-webbook-nacl.txt",
      "text_bytes": 6724
    }
  ],
  "retrieval_note": "Legacy mail.iapws.org endpoint failed TLS hostname verification; used current official IAPWS download instead, without disabling TLS verification.",
  "derived_files": [
    {
      "file": "archer-1992-nacl-water-ocr.txt",
      "bytes": 147294,
      "sha256": "7a6763c4f9c0d9446ab38e130f0148dbaccc1266aa0da9d72157a594d354a879",
      "kind": "OCR transcription, not authoritative"
    },
    {
      "file": "water-density-evaluation.json",
      "bytes": 724,
      "sha256": "9a11bb276e7a333db316c0f060b28a52009294d53c565e4f5372a6731b8d455c",
      "kind": "Operator arithmetic evaluation, not measured data"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '430,570p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt; sed -n '920,1060p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt; cat /work/checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-023-01322-y

{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T15:48:51.378080+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00",
        "extracted_sha256": "c188ba83248d2abd315750f0a061b8f321e10686bc14ccbe677aa38301a8db00"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "mixedTemperature": true,
      "netPower": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B W k A F B0 L U x : \u211d), 0 < C \u2192 0 < C + S \u2192 0 < k \u2192 F \u2264 initialTemperature \u2192 initialTemperature \u2264 L \u2192 L \u2264 U \u2192 U \u2264 B0 \u2192 F \u2264 mixedTemperature C S H Ts L \u2192 mixedTemperature C S H Ts U \u2264 B \u2192 0 < netPower W k A U \u2192 0 < netPower W k A B \u2192 x \u2208 Set.Icc L U \u2192 netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x = k * (S * (x - Ts) + H) / (C + S) \u2227 (0 \u2264 S \u2192 0 \u2264 S * (L - Ts) + H \u2192 boilingTime C S H Ts B W k A L \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 \u2264 S \u2192 S * (U - Ts) + H \u2264 0 \u2192 boilingTime C S H Ts B W k A U \u2264 boilingTime C S H Ts B W k A x) \u2227 (0 < S \u2192 Ts - H / S \u2208 Set.Icc L U \u2192 boilingTime C S H Ts B W k A (Ts - H / S) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S \u2264 0 \u2192 min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) \u2264 boilingTime C S H Ts B W k A x) \u2227 (S = 0 \u2192 H = 0 \u2192 boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x)"
    },
    "extracted_file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '1160,1250p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt; grep -n -E '4.2.4|4.2.5|heat capacit|Heat Capacit|p1|TABLE 4|Table 4' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt | head -45; cat /work/lean-env.sh\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-023-01322-y

https://doi.org/10.1063/1.555915

export LEAN_PATH=/harness/.lake/packages/plausible/.lake/build/lib/lean:/harness/.lake/packages/proofwidgets/.lake/build/lib/lean:/harness/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/harness/.lake/packages/mathlib/.lake/build/lib/lean:/harness/.lake/packages/aesop/.lake/build/lib/lean:/harness/.lake/packages/batteries/.lake/build/lib/lean:/harness/.lake/packages/importGraph/.lake/build/lib/lean:/harness/.lake/packages/Qq/.lake/build/lib/lean
shell input
{
  "command": "/usr/bin/bash -lc \"cat /work/inputs/material-evidence-001/nist-janaf-nacl-solid.txt; sed -n '1045,1075p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt; sed -n '395,445p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-023-01322-y

https://janaf.nist.gov/tables/Cl-055.html
shell input
{
  "command": "/usr/bin/bash -lc 'mkdir -p /work/history/cycle5-start /work/evidence/cycle5'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'cp /work/Model.lean /work/candidate.json /work/report.txt /work/history/cycle5-start/'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport math\nm=10/(58.443*.99820675)\nf=(m-.15)/.05\nv=(-.8329+f*(.8329-.0527))*1e-3\nq=(-60.2+f*(-73.5+60.2))*1e-6\nrel=lambda t: -(t+273.15)**2*(v+2*q*t)\nhi20=4481+(20-19.97)*(3824-4481)/(25-19.97)\nhi100=-4540+(100-95.18)*(-4540+3222)/(95.18-84.98)\nh20=hi20+rel(20)\nd100=hi100+51*80+rel(100)\ns=(d100-h20)/80\nprint(dict(m=m,v=v,q=q,relative20=rel(20),relative100=rel(100),h20=h20,d100=d100,s=s))\npts=[(19.97,4481),(25,3824),(34.96,2573),(45,1423),(54.83,335),(64.86,-837),(75.01,-2038),(84.98,-3222),(95.18,-4540)]\nfor t,hi in pts:\n d=hi+51*(t-20)+rel(t)\n fit=h20+s*(t-20)\n print(t,'D',round(d,2),'affine residual',round(d-fit,2))\nPY\""
}
shell output · exit 0
{'m': 0.17141427913053023, 'v': -0.0004987515884472062, 'q': -6.589619824872105e-05, 'relative20': 269.3778358809385, 'relative100': 1904.53611795269, 'h20': 4746.4593468153325, 'd100': 821.7165101095534, 's': -49.05928545882224}
19.97 D 4748.45 affine residual 0.52
25 D 4416.22 affine residual -84.94
34.96 D 3820.7 affine residual -191.83
45 D 3348.78 affine residual -171.2
54.83 D 2942.31 affine residual -95.42
64.86 D 2484.46 affine residual -61.2
75.01 D 2026.27 affine residual -21.44
84.98 D 1592.39 affine residual 33.8
95.18 D 1063.65 affine residual 5.47
assistant
A reference-consistent calculation gives a promising result for the selected 10 g NaCl case. A secant fit to the literature enthalpies gives about 813 J of dissolution energy at 20 °C and a signed capacity change of about −8.4 J/K. In this effective model, adding the salt still cools the water throughout the range before unsalted boiling, so the derived timing law favors immediate addition.

I’ll make the interpolation, short extrapolation toward 100 °C, and constant-capacity approximation explicit. These are modeled estimates, not measurements of your pot.
shell input
{
  "command": "/usr/bin/bash -lc \"cat >> /work/Model.lean <<'EOF'\n\n/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443\n   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.\n   PI(con) v and q are linearly interpolated between the published .15\n   and .20 mol/kg entries. This is an empirical interpolation, not new data.\n   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/\nnoncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=\n  let m := 10 / (58.443 * 0.99820675)\n  let f := (m - 0.15) / 0.05\n  let v := (-0.8329 + f * 0.7802) / 1000\n  let q := (-60.2 - f * 13.3) / 1000000\n  -(t + 273.15)\"'^2 * (v + 2 * q * t)\n\n/- Integral dissolution energy, joules, at the actual salt/reference\n   temperature 20 C. Interpolate Criss-Cobble'\"'s 19.97 and 25 C standard\n   solid-dissolution data, THEN add the same-temperature relative term. -/\nnoncomputable def naclDissolutionAt20 : ℝ :=\n  (10 / 58.443) *\n    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)\n\n/- Effective constant solution-minus-water capacity, J/K, inferred as\n   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed\n   at 20 C. It is NOT the local heat capacity at 25 C.\n   Extend the last measured standard-dissolution segment (84.98,95.18 C)\n   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and\n   the finite-concentration correction. These extensions/approximations\n   are explicit empirical scenario choices, not certified error bounds. -/\nnoncomputable def naclCapacityChange : ℝ :=\n  ((10 / 58.443) *\n    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +\n      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80\n\n/- Derived material signs/bounds. No assumed sign for total capacity\n   change; these follow from the stated data and interpolation model. -/\nlemma nacl_material_inference :\n    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧\n    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by\n  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]\n\n/- Physical answer for the chosen case: salt and room at 20 C;\n   water+pot effective capacity C>=3900 J/K; atmospheric unsalted\n   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;\n   heater can reach B despite losses. Any addition temperature x from\n   the initial 20 C through onset of UNSALTED boiling is allowed.\n   Concludes positive total capacity, liquid postmix state (>=19 C),\n   increased net power after mixing, and immediate addition minimizes\n   time to brine boiling over the WHOLE admissible timing domain. -/\ntheorem nacl_immediate_addition_answer :\n    ∀ (C W k B0 B x : ℝ),\n    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ 100.1 →\n    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →\n    x ∈ Set.Icc initialTemperature B0 →\n    0 < C + naclCapacityChange ∧\n    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧\n      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧\n    (0 < netPower W k 20 x ∧\n      netPower W k 20 x <\n        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧\n    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤\n      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by\n  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx\n  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference\n  have hc : 0 < C + naclCapacityChange := by linarith\n  have hc0 : 0 < C := by linarith\n  have hi : initialTemperature = 20 := rfl\n  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,\n      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by\n    intro y hy\n    rw [hi] at hy\n    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=\n      mul_nonneg (by linarith) (by linarith [hy.1])\n    nlinarith [hy.2]\n  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,\n      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by\n    intro y hy\n    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)\n    have hd := hcool y hy\n    nlinarith\n  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by\n    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)\n    rw [hi] at hb\n    nlinarith\n  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith\n  have hpow0 : 0 < netPower W k 20 B0 := by\n    unfold netPower at *\n    nlinarith\n  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith\n  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=\n    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB\n  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20\n    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)\n    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx\n  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)\n  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by\n    rw [hj]\n    exact div_pos (mul_pos hk (hcool x hx)) hc\n  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,\n    ⟨feasible.2.2.1, by linarith⟩, ?_⟩\n  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20\n    initialTemperature x hc0 hc hk hx.1\n  · intro y hy\n    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20\n      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)\n      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB\n      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2\n  · intro y hy\n    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)\nEOF\nsource /work/lean-env.sh\n/harness/.elan/bin/lean /work/Model.lean > /work/evidence/cycle5/local-lean-1.log 2>&1\""
}
shell output · exit 127 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle5/local-lean-1.log; command -v lean; ls /harness; find /opt -maxdepth 4 -name lean -type f 2>/dev/null'"
}
shell output · exit 0
/usr/bin/bash: line 111: /harness/.elan/bin/lean: No such file or directory
entrypoint.sh
lean-toolchain
src
/opt/lean/bin/lean
shell input
{
  "command": "/usr/bin/bash -lc 'source /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle5/local-lean-2.log 2>&1'"
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/human-feedback.json; cat /work/history/cycle3/candidate.json'"
}
shell output · exit 0
{
  "decision": "reject",
  "binding": "f797b3f8a1d3e63d150060fcb98fab141b21fa029b778c95b9cbd3fb3191af67",
  "reason": "Human review of attempt 003: connect the conditional timing theorem to a justified physical case.\n\nHuman instruction, verbatim:\n\"We are not asking for numerical result, so that's OK. Just ask codex to connect his case with some assumptions about reality. Btw, what claude do we use? Sonnet?\"\n\nThe human accepts the shared constant-input Newtonian heating/loss approximation netPower(W,k,A,T) = W - k*(T-A), with the same law before and after salting. Keep the useful signed-capacity timing theorem and its energy-balance derivations.\n\nChoose and justify a concrete physical scenario consistent with the original one-litre, 20 C water task: specify the salt, a reasonable amount or concentration regime, initial salt/environmental conditions and relevant applicability assumptions. Use verified literature, physical relationships and explicit scenario assumptions to establish which of your conditional timing cases actually applies. In particular, establish the necessary heat-capacity-change and dissolution-energy signs/bounds with the correct enthalpy reference, rather than leaving S and H wholly unspecified or assuming the desired optimum. Material-property data or explicitly justified empirical models can be scientific premises; derive their consequences and the qualitative optimal timing in Lean. Derive the domain/positivity conditions you can from the chosen case and expose any remaining apparatus assumptions for human review. Do not allow waiting through unsalted boiling or an inadmissible mixing/phase state merely to obtain an optimum.\n\nA numerical time saving, a numerical heating duration, or a particular number of seconds is NOT required. A physically motivated case with a formally established recommendation such as earliest feasible addition is a sufficient target if your chosen physical assumptions imply it. Select and derive the appropriate recommendation independently; do not force that example recommendation as a premise. Preserve the existing original observations and provenance, avoid invented experiments and unverified recalled citations, and keep the assumptions/conclusions readable. You may request specific missing evidence through the existing protocol.\n\nNo other agent's model, parameter choices, numerical results or proof are supplied. This feedback requests revision, not full acceptance of attempt 003.\n",
  "time": "2026-11-17T22:50:26.998356+00:00",
  "verification_verdict": "proved"
}
{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "addition_timing_answer"
  },
  "user_facts": [
    "One litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.",
    "Salt will be added; salt quantity, pot, heater and room conditions are otherwise unspecified."
  ],
  "model_choices": [
    "Deterministic lumped constant-capacity model with original water-plus-pot C>0 and final solution-plus-pot C+S>0; S is the signed solution-minus-water capacity difference, never assumed nonnegative. Pot initially equilibrated at 20 C.",
    "Fixed soluble salt amount, final composition, pressure, salt temperature Ts, unsalted boiling B0 and solution boiling B across schedules. H is integral isothermal dissolution enthalpy at Ts (either sign); affine enthalpies imply dissolution enthalpy H+(S-cs)*(T-Ts) at T for solid salt capacity cs, not a constant dissolution heat at all temperatures.",
    "Instantaneous adiabatic mixing and complete dissolution; no heating interruption, evaporation, phase changes before endpoint or material loss. Constant capacities and the liquid/soluble regime are conditional approximations, not inferred material properties.",
    "Shared before/after net power N(T)=W-k*(T-A), constant heater input and room temperature, k>0; no independent salinity dependence of heat transfer. Heating obeys capacity*dT/dt=N(T).",
    "Compare a nonempty feasible interval [L,U] with F<=20<=L<=U<=B0, F<=z(L), z(U)<=B, N(U)>0 and N(B)>0. F is a safe common liquid lower bound; these constraints enforce liquid heating stages. Endpoint onsets of boiling are permitted without dwelling. Use full feasible interval for a global physical scheduling optimum."
  ],
  "sources": [
    "https://link.springer.com/article/10.1007/s10953-024-01412-5",
    "https://link.springer.com/article/10.1007/s10953-023-01322-y"
  ],
  "incorporated_inputs": [],
  "proof_scope": "Derives reference-consistent mixing balance with signed heat-capacity change, the net-power jump from the shared heater/loss law, stage-time integration and uniqueness from the inverse first law, and the derivative of full boiling time. Proves global earliest/latest/interior-root regimes for S>=0 and endpoint minimum for S<=0, including the S=H=0 tie, on an explicitly feasible liquid interval. No parameter values or material-property signs are inferred from absent observations; physical validity and regime selection remain for human review. No additional axioms, sorry, external responses, experiments or human approval are claimed."
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle5/local-lean-2.log'"
}
shell output · exit 0
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/evidence/cycle5/evaluate_material_model.py <<'PY'\n\\\"\\\"\\\"Arithmetic from supplied literature, NOT a physical experiment.\nUses explicit empirical interpolations/extrapolations described in report.txt.\nStandard library only. Decimal arithmetic is for review, Lean checks rationals.\n\\\"\\\"\\\"\nimport json\nfrom fractions import Fraction as F\nfrom pathlib import Path\nr=lambda x:F(str(x))\nn=r(10)/r(58.443)\nm=n/r(.99820675)\nf=(m-r(.15))/r(.05)\nv=(-r(.8329)+f*r(.7802))/1000\nq=(-r(60.2)-f*r(13.3))/1000000\nrel=lambda t:-(t+r(273.15))**2*(v+2*q*t)\nhi20=r(4481)-(r(20)-r(19.97))*657/(25-r(19.97))\nhi100=-r(4540)-(r(100)-r(95.18))*1318/(r(95.18)-r(84.98))\nh=hi20+rel(r(20))\nd100=hi100+51*80+rel(r(100))\ns=(d100-h)/80\nrows=[]\nfor t,hi in [('19.97',4481),('25',3824),('34.96',2573),('45',1423),('54.83',335),('64.86',-837),('75.01',-2038),('84.98',-3222),('95.18',-4540)]:\n    t=r(t)\n    d=hi+51*(t-20)+rel(t)\n    fit=h+s*(t-20)\n    rows.append(dict(temperature_C=float(t),cooling_energy_per_mol_J=float(d),secant_residual_J_per_mol=float(d-fit)))\nresult=dict(kind='calculated empirical model, not measurement or certified error interval',salt_moles=float(n),molality=float(m),v=float(v),q=float(q),dissolution_at_20_J_per_mol=float(h),cooling_energy_at_100_J_per_mol=float(d100),secant_capacity_change_J_per_mol_K=float(s),total_dissolution_at_20_J=float(n*h),total_capacity_change_J_per_K=float(n*s),sampled_enthalpy_residuals=rows,limitations='Concentration interpolation, solid Cp=51 approximation, linear extrapolation of standard dissolution enthalpy from 95.18 to 100 C. Sampled residuals do not certify a uniform bound. Effective affine model continued to 19..101 C. Source response f7c987a52391410bb035542305825b3f; no apparatus observations.')\nPath('/work/evidence/cycle5/material-model-evaluation.json').write_text(json.dumps(result,indent=2)+'\\\\n')\nprint(json.dumps(result,indent=2))\nPY\npython /work/evidence/cycle5/evaluate_material_model.py > /work/evidence/cycle5/material-model-calculation.log\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/report.txt <<'EOF'\nCycle 5 revision: a literature-calibrated dilute NaCl example\n\nAnswer and limits\n\nThe original observations do not specify a universal addition temperature or a number of seconds. The salt, amount, salt temperature and heating apparatus affect the answer. For the explicit 10 g dry NaCl example below, the derived effective enthalpy model predicts: add it immediately, at the initial water temperature 20 C (elapsed heating time zero). This is a conditional scientific prediction, not a measurement, and not an unconditional recommendation for every salt or apparatus.\n\nThe new theorem nacl_immediate_addition_answer establishes this over the complete scheduling domain from 20 C to the onset of unsalted boiling. It also derives positive final heat capacity, a liquid postmix temperature and the increase in net heating power. It never compares schedules that dwell at unsalted boiling. No seconds or magnitude of time saving is inferred. The inequality establishes a minimizer; it does not formally assert uniqueness.\n\nSupplied information and provenance\n\nThe user supplied one litre of water initially at 20 C, a pot and a stove, with the salt quantity, pot, heater and room otherwise unspecified. All other scenario conditions below are researcher choices, not observations of this kitchen.\n\nEarlier cycles: the shared constant-input, Newtonian heat-loss law was accepted as an approximation. Human feedback rejected treating before/after powers as independent, then rejected presuming a nonnegative heat-capacity change, and finally requested a concrete physical case supported by material evidence. The cycle-3 check compiled and independently extracted the signed-capacity theorem (checks/8ce875bbeedf40f384474d008e4dfa66); that mathematical result was not human acceptance of its scientific sufficiency. Older extraction failures and their diagnostics remain in checks/. Cycle 4 requested material literature. This revision incorporates external response f7c987a52391410bb035542305825b3f, whose source bundle is inputs/material-evidence-001/. It supplies primary literature, not a physical experiment or a timing conclusion. Original cycle-5-start files are preserved in history/cycle5-start/.\n\nConcrete scenario and material inference\n\nChoose 10 g pure dry crystalline NaCl stored at 20 C, with the room also at 20 C and approximately atmospheric pressure. This is a modest culinary concentration, chosen before receiving material values in cycle 4 and retained unchanged. NIST GLP10 gives water density at 20 C of 0.99820675 g/cm3 (air-free reference); one reference litre is therefore 0.99820675 kg. Using NIST's NaCl molar mass 58.443 g/mol gives n=10/58.443=0.1711062 mol and m=n/0.99820675=0.1714143 mol/kg. Actual volume, purity and pressure uncertainties were not supplied. These nominal reference conversions are empirical model inputs, not an inference about their experimental precision.\n\nWe use finite-concentration enthalpies rather than misidentifying relative apparent capacities as absolute ones. Partanen & Partanen (2023), Table 2, gives PI(con) parameters at molalities 0.15 and 0.20. In units J, mol and K these are:\n m=.15: v=-.8329e-3, q=-60.2e-6;\n m=.20: v=-.0527e-3, q=-73.5e-6.\nWe linearly interpolate v and q in molality between these two neighboring tabulated compositions. With Celsius t and absolute T=t+273.15, their Eq. 19 (also 2025 Eq. 18) gives the relative apparent molar enthalpy\n L(t)=-(t+273.15)\"'^2 [v+2 q t].\nLean'\"'s naclRelativeEnthalpy exposes this exact interpolation. It gives L(20)=269.38 and L(100)=1904.54 J/mol. This empirical interpolation is distinct from directly evaluating the full Hückel model at m; it uses published model outputs, not a newly fitted physical measurement.\n\nFor the infinite-dilution isothermal SOLID dissolution enthalpy, Partanen2023 Table 8 reproduces Criss & Cobble: 4481 J/mol at the actual 19.97 C and 3824 at 25 C. Linear interpolation to 20 C gives h_inf(20)=4477.08 J/mol. The finite-concentration isothermal solid dissolution energy is h20=h_inf(20)+L(20)=4746.46 J/mol. The total H=n*h20 is about 812.17 J. It is referenced to dissolution with both solid salt and water at 20 C, not at the later addition temperature. Lean's naclDissolutionAt20 makes this conversion explicit.\n\nWe construct an EFFECTIVE CONSTANT heat-capacity change using an enthalpy secant. This is a model reduction, not a claim that local heat capacity is constant. Table 8 gives -3222 J/mol at 84.98 C and -4540 at 95.18 C. Extend this last standard-dissolution segment linearly by 4.82 K to 100 C:\n h_inf(100)=-4540-(100-95.18)*1318/(95.18-84.98).\nFor the solid sensible enthalpy from 20 to 100 C, use the approximation c_s=51 J/(mol K). NIST-JANAF gives Cp=50.509 at 298.15 K, 50.543 at 300 K, 52.350 at 400 K. Thus 51 is a reasonable effective value for this interval, though it is an explicit approximation; the WebBook Shomate fit starting at 298 K is NOT claimed validated at 293 K. The reference-consistent apparent energy with solid held at 20 C is\n D_mol(t)=h_inf(t)+c_s*(t-20)+L(t).\nAt 100 C the calculation gives D_mol=821.72 J/mol. Define the effective signed capacity increment by its secant\n s_eff=[D_mol(100)-h20]/80=-49.0593 J/(mol K),\n S=n*s_eff=-8.39446 J/K.\nLean's naclCapacityChange derives this from the source numbers and exposed interpolation choices. It does not assume S>=0, and does not use dissolution-enthalpy slope alone as S: the solid sensible-heat reference conversion is essential.\n\nThe affine effective apparent enthalpy is n*[h20+s_eff*(t-20)]. Consequently it honors the calibrated apparent enthalpy at both endpoints. The proof derives the conservative rational bounds 810<=H<=820 J and -9<=S<=-8 J/K from these formulas, rather than adopting those bounds as independent premises.\n\nWhy this reduction, and what it does not establish\n\nThe accepted lumped model uses constant capacities. Fitting its signed increment to an enthalpy secant preserves the integrated 20-to-100 C energy difference instead of extending a local 25 C capacity over 80 K. As a diagnostic, evaluating D_mol at all nine supplied Criss-Cobble temperatures from 19.97 to 95.18 C and using the same finite-concentration correction gives residuals against this secant between about -192 and +34 J/mol (total absolute discrepancy <=33 J for the chosen amount). The predicted cooling energy at 100 C is about 141 J, so these sampled discrepancies are smaller than its sign margin. This supports the qualitative approximation; it is NOT a certified uniform interpolation error, a new measurement, or a theorem about variable-capacity real brine. Local capacities vary, and the formal answer remains conditional on the affine effective enthalpy model, extended over the used 19-to-101 C interval. The 95.18-to-100 C extrapolation has no newly certified confidence interval. These are independent scientific limitations for human review, not hidden axioms or unreported experimental validation.\n\nWe do not combine the 2025 Table 2 absolute capacity baseline -84 J/(mol K) with its alternative Eq.22 baseline -8-2t. The source itself discusses baseline discrepancies for dilute brine. Such mixing would destroy the reference consistency. Here 2025 Eqs.9-10 justify capacity as an enthalpy derivative; the numerical calibration uses the coherent solid-dissolution reference from 2023 plus the stated solid sensible heat.\n\nNo probability distribution is needed: this is a deterministic thermodynamic reduction calibrated to published nominal values. The supplied observations cannot identify heater input, heat loss or pot capacity, so no numerical duration is inferred. No prior, synthetic experiment or device measurement has been invented.\n\nPhysical model and formal inference\n\nC is the original effective water-plus-pot heat capacity in J/K, with C>=3900. About .9982 kg liquid water has heat capacity roughly 4.2 kJ/K near these temperatures (IAPWS95); a nonnegative equilibrated pot capacity increases this. The lower bound is conservative, but remains a scenario/applicability premise rather than a measured pot property. We retain instantaneous complete dissolution and adiabatic mixing, no heating interruption, negligible evaporation or change of composition, and uniform water/pot temperature. The modest .1714 mol/kg concentration is far below the roughly 6 mol/kg saturation-scale compositions studied in the supplied primary papers. Full dissolution, no transient local phase problem and maintenance of the chosen liquid composition are applicability assumptions. The comparison includes neither evaporation losses nor the time spent pouring or stirring.\n\nThe same net heat flow applies before and after salting:\n N(T)=W-k*(T-20), k>0, with constant input W.\nNo salinity-dependent heat-transfer change is assumed. This is the approximation accepted in earlier feedback. A different real heat-transfer law can alter the result.\n\nAffine enthalpy conservation at addition temperature x gives\n (C+S)*z = C*x+S*20-H,\n z=(C*x+S*20-H)/(C+S).\nThe previous reference_consistent_balance lemma proves that this is equivalent to heating the solid to x and dissolving there with dissolution heat H+(S-c_s)*(x-20). It uses one reference consistently. S is the full solution-minus-original-water capacity difference, with pot unchanged, and can be negative.\n\nThe net-power change is DERIVED, not supplied:\n N(z)-N(x) = k*[H+S*(x-20)]/(C+S).\nFor this calibrated case the proof derives C+S>0 and H+S*(x-20)>0 for every 20<=x<=B0<=100.1. Indeed the loose material bounds give at least 810-9*80.1=89.1 J. Therefore mixing cools the water and increases its net heating power even though S<0. Lower mixture heat capacity does not by itself determine the sign of the temperature jump.\n\nHeating obeys capacity*dT/dt=N(T). heatingTime is the integrated inverse first law:\n h(K,u,v)=K/k * log[N(u)/N(v)].\nThe Lean stage_time_from_energy lemma proves that any elapsed-time function with derivative K/N(T) and zero starting time equals this integral, so the final theorem is not just arithmetic on an externally calculated answer. With final brine boiling B, total time is\n tau(x)=h(C,20,x)+h(C+S,z(x),B).\nThe proof differentiates the ENTIRE schedule, including the mixing jump, and derives\n tau'(x)=C*k*[H+S*(x-20)] / [(C+S)*N(x)*N(z(x))].\nPositive powers and capacities make this nonnegative across the whole feasible scheduling domain. A mean-value monotonicity theorem then proves tau(20)<=tau(x). This is the scientific inference behind immediate addition. The generic signed-capacity timing theorem and its derivations from cycle 3 are retained as supporting work.\n\nDomain and apparatus review boundary\n\nThe final theorem assumes 99<=B0<=100.1 C, B0<=B<=101 C, and W>k*(B-20). These give a conservative approximately atmospheric liquid boiling domain and sufficient heater power to reach the final endpoint. IAPWS95 supports the pure-water endpoint; the small elevation is physically consistent with dilute NaCl (the leading dilute estimate is approximately 2*0.512*.1714=0.176 K), but those numerical boiling bounds are exposed scenario assumptions, not a formally solved activity/equilibrium model or measured pressure. Only final brine, not unsalted water, is heated above B0.\n\nThe comparison domain is exactly 20<=x<=B0. B0 means onset of unsalted boiling, with immediate addition and no dwell. From the material inference and C bound, Lean derives the earliest mixed temperature >=19 C. Monotonicity of z(x) gives the same lower bound throughout. Cooling gives z(x)<=x<=B0<=B. Positive N(B) ensures positive heat flow everywhere on each liquid heating stage. Thus the proof derives the important state and positivity conditions from the case; they are not imported as a long list of unrelated trajectory hypotheses.\n\nCompact review packet\n\nSupplied facts: 1 L initial water at 20 C; unspecified salt/pot/heater/room.\n\nAdditional choices: 10 g pure crystalline NaCl at 20 C; room 20 C; nominal density/molar-mass conversion; the explicit published-data interpolation and short standard-enthalpy extrapolation; c_s=51; effective affine enthalpies on 19..101 C; complete instantaneous dissolution and mixing with negligible evaporation; shared constant-input Newtonian losses; C>=3900; the stated approximately atmospheric boiling bounds; heater strong enough to reach B. None is presented as an observed apparatus parameter or as inferred from the user's volume and temperature alone.\n\nNecessary definitions: initialTemperature=20, netPower, mixedTemperature, integrated heatingTime and full boilingTime; naclRelativeEnthalpy, naclDissolutionAt20 and naclCapacityChange contain the complete material calibration. Units and references are stated above and alongside Lean definitions.\n\nProved conclusion: nacl_immediate_addition_answer: for all such apparatus parameters and all additions before/on unsalted boiling, final capacity is positive, postmix state is at least 19 C and no hotter than the preaddition water, net power increases, and immediate addition minimizes time to salted boiling. Material signs, mixing law, net-power jump, integrated stage-time law and monotonic timing inference are proved intermediates. No sorry or extra axiom is used. Compilation/extraction/kernel checking assess this conditional mathematical statement; empirical accuracy and human acceptance remain separate.\n\nSources actually incorporated\n\nExternal response f7c987a52391410bb035542305825b3f, supplied source PDFs/texts and sources.json with hashes:\n NIST GLP10, density at 20 C: https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf\n Partanen & Partanen 2023, DOI 10.1007/s10953-023-01322-y, Eqs.13-19 and Tables 2,8: https://doi.org/10.1007/s10953-023-01322-y\n Partanen & Partanen 2025, DOI 10.1007/s10953-024-01412-5, Eqs.9-10,18 and baseline discussion: https://doi.org/10.1007/s10953-024-01412-5\n NIST-JANAF crystalline NaCl sensible-heat guidance: https://janaf.nist.gov/tables/Cl-055.html\n NIST WebBook molar mass and correlation range: https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2\n IAPWS R6-95(2018), pure-water thermal and phase relationships: https://iapws.org/technical-guidance/release/IAPWS-95\n\nThe bundle's Archer PDF/OCR is not used for numerical calibration. No unverified OCR coefficients are used. Arithmetic and sampled residuals are reproducible in evidence/cycle5/evaluate_material_model.py and material-model-evaluation.json. These are calculations about the chosen empirical model, not external responses or independent measurements.\nEOF\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle5/local-lean-2.log; head -18 /work/evidence/cycle5/material-model-evaluation.json'"
}
shell output · exit 0
/work/Model.lean:109:37: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:113:34: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:109:37: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/Model.lean:113:34: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/Model.lean:160:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:160:8: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:160:8: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
/work/Model.lean:299:6: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:299:6: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/Model.lean:337:35: error: unexpected token 'noncomputable'; expected term
/work/Model.lean:362:57: error: unsolved goals
⊢ 810 ≤ 10000 / 58443 * (2251972 / 503 + sorry ()) ∧
    10000 / 58443 * (2251972 / 503 + sorry ()) ≤ 820 ∧
      -9 ≤ (10000 / 58443 * (-(276119 / 255) + sorry ()) - 10000 / 58443 * (2251972 / 503 + sorry ())) / 80 ∧
        (10000 / 58443 * (-(276119 / 255) + sorry ()) - 10000 / 58443 * (2251972 / 503 + sorry ())) / 80 ≤ -8
/work/Model.lean:363:53: warning: declaration uses `sorry`
/work/Model.lean:407:4: error: linarith failed to find a contradiction
C W k B0 B x : ℝ
hC : 3900 ≤ C
hk : 0 < k
hBlo : 99 ≤ B0
hBhi : B0 ≤ 100.1
hB : B0 ≤ B
hBmax : B ≤ 101
hW : k * (B - 20) < W
hx : x ∈ Set.Icc initialTemperature B0
hHlo : 810 ≤ naclDissolutionAt20
hHhi : naclDissolutionAt20 ≤ 820
hSlo : -9 ≤ naclCapacityChange
hShi : naclCapacityChange ≤ -8
hc : 0 < C + naclCapacityChange
hc0 : 0 < C
hi : initialTemperature = 20
hcool : ∀ y ∈ Set.Icc initialTemperature B0, 0 < naclCapacityChange * (y - 20) + naclDissolutionAt20
hzbelow : ∀ y ∈ Set.Icc initialTemperature B0, mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y
hb :
  (C + naclCapacityChange) * mixedTemperature C naclCapacityChange naclDissolutionAt20 20 20 =
    C * 20 + naclCapacityChange * 20 - naclDissolutionAt20
a✝ : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature < 19
⊢ False
failed
{
  "kind": "calculated empirical model, not measurement or certified error interval",
  "salt_moles": 0.1711068904744794,
  "molality": 0.17141427913053023,
  "v": -0.0004987515884472063,
  "q": -6.589619824872104e-05,
  "dissolution_at_20_J_per_mol": 4746.4593468153325,
  "cooling_energy_at_100_J_per_mol": 821.7165101095526,
  "secant_capacity_change_J_per_mol_K": -49.059285458822245,
  "total_dissolution_at_20_J": 812.1518995971,
  "total_capacity_change_J_per_K": -8.394381783758918,
  "sampled_enthalpy_residuals": [
    {
      "temperature_C": 19.97,
      "cooling_energy_per_mol_J": 4748.452998781568,
      "secant_residual_J_per_mol": 0.5218734024709595
    },
    {
shell input
{
  "command": "/usr/bin/bash -lc \"nl -ba /work/Model.lean | sed -n '325,343p'; nl -ba /work/Model.lean | sed -n '400,410p'\""
}
shell output · exit 0
   325	      simp [hS, hH]
   326	
   327	/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   328	   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   329	   PI(con) v and q are linearly interpolated between the published .15
   330	   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   331	   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
   332	noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
   333	  let m := 10 / (58.443 * 0.99820675)
   334	  let f := (m - 0.15) / 0.05
   335	  let v := (-0.8329 + f * 0.7802) / 1000
   336	  let q := (-60.2 - f * 13.3) / 1000000
   337	  -(t + 273.15)^2 * (v + 2 * q * t)
   338	
   339	/- Integral dissolution energy, joules, at the actual salt/reference
   340	   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   341	   solid-dissolution data, THEN add the same-temperature relative term. -/
   342	noncomputable def naclDissolutionAt20 : ℝ :=
   343	  (10 / 58.443) *
   400	    intro y hy
   401	    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
   402	    have hd := hcool y hy
   403	    nlinarith
   404	  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
   405	    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
   406	    rw [hi] at hb
   407	    nlinarith
   408	  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
   409	  have hpow0 : 0 < netPower W k 20 B0 := by
   410	    unfold netPower at *
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'\ns=open(p).read().replace('let m := 10 / (58.443 * 0.99820675)','let m : ℝ := 10 / (58.443 * 0.99820675)').replace('let q := (-60.2 - f * 13.3) / 1000000\\\\n','let q := (-60.2 - f * 13.3) / 1000000;\\\\n').replace('    rw [hi] at hb\\\\n    nlinarith\\\\n','    rw [hi] at hb ⊢\\\\n    nlinarith\\\\n')\nopen(p,'w').write(s)\np='/work/report.txt';s=open(p).read().replace('0.1711062 mol','0.1711069 mol').replace('812.17 J','812.15 J').replace('-8.39446 J/K','-8.39438 J/K');open(p,'w').write(s)\nPY\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle5/local-lean-3.log 2>&1\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport json\np='/work/candidate.json'\nc={\n 'proof_file':'Model.lean','narrative_file':'report.txt',\n 'conclusions':{'answer':'nacl_immediate_addition_answer'},\n 'user_facts':['One litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.','Salt will be added; salt quantity, pot, heater and room conditions otherwise unspecified.'],\n 'model_choices':[\n 'Scenario retained from cycle 4: 10 g pure dry crystalline NaCl held at 20 C before addition; ambient and initially equilibrated pot at 20 C; approximately atmospheric pressure. Nominal solvent mass .99820675 kg from NIST 20 C density and molar mass 58.443 g/mol determine .1714143 mol/kg.',\n 'Use published Partanen2023 PI(con) relative enthalpy expression, interpolating its v,q between .15 and .20 mol/kg. Standard solid dissolution enthalpy at 20 C is interpolated from actual 19.97 and 25 C entries in its Table 8. Add same-temperature finite-concentration correction; derive H, do not assume its sign.',\n 'Effective constant signed solution-minus-water heat capacity S is the 20-to-100 C apparent-enthalpy secant with solid salt referenced to 20 C. Standard dissolution enthalpy at 100 C is linearly extrapolated from 84.98 and 95.18 C values; solid sensible heat uses effective 51 J/(mol K), guided by NIST-JANAF. Derive S from these inputs, not from a preset sign. This affine effective enthalpy model is used on 19..101 C; it is a reduction, not a uniform local-capacity bound. Sampled residuals are disclosed; extrapolation and uniform physical accuracy have no certified uncertainty bound.',\n 'Shared constant-input Newtonian heat flow N(T)=W-k*(T-20), k>0, unchanged by salinity. Heating obeys capacity*dT/dt=N(T); constant water+pot capacity C>=3900 J/K. Affine enthalpies, instantaneous adiabatic complete dissolution, no heating interruption, negligible evaporation and material loss; uniform liquid/pot temperature.',\n 'Unsalted boiling B0 satisfies 99<=B0<=100.1 C; final brine boiling satisfies B0<=B<=101 C. Assume enough power W>k*(B-20). Compare all additions 20<=x<=B0, allowing only the onset of unsalted boiling without dwelling. Liquid/solubility applicability is explicit. The proof derives positive final capacity, postmix temperature>=19 C, postmix temperature<=x<=B, and positive heat flow.'\n ],\n 'sources':[\n 'Operator source bundle /work/inputs/material-evidence-001/sources.json, with original PDFs/text and SHA256 hashes; response f7c987a52391410bb035542305825b3f.',\n 'https://doi.org/10.1007/s10953-023-01322-y — Partanen2023 Eqs.13-19 and Tables 2,8; Table 8 attributes standard solid dissolution data to Criss and Cobble.',\n 'https://doi.org/10.1007/s10953-024-01412-5 — Partanen2025 Eqs.9-10,18 and discussion of competing absolute heat-capacity baselines.',\n 'https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf — GLP10 water density.',\n 'https://janaf.nist.gov/tables/Cl-055.html — crystalline NaCl heat capacity.',\n 'https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2 — molar mass and solid correlation validity limits.',\n 'https://iapws.org/technical-guidance/release/IAPWS-95 — pure-water thermal and phase relationships.'\n ],\n 'incorporated_inputs':['f7c987a52391410bb035542305825b3f'],\n 'proof_scope':'For the explicit literature-calibrated effective affine-enthalpy NaCl case, derives signed capacity/dissolution bounds, positive final capacity, feasible liquid mixing temperatures, net-power increase from energy conservation and the shared loss law, and immediate addition as a global minimizer over 20 C through onset of unsalted boiling. Retains signed-capacity and reference-consistent balance derivations, stage-time uniqueness from inverse energy balance, and full-schedule derivative/monotonicity proof. No sorry or additional axiom. Conditional on exposed empirical interpolation/extrapolation, effective constant-capacity reduction, phase and apparatus premises; does not certify their physical accuracy, infer a numerical duration, resolve all unspecified salts/apparatus, or claim human approval. Raw calculations and Lean diagnostics preserved in evidence/cycle5/.'\n}\nopen(p,'w').write(json.dumps(c,indent=2)+'\\\\n')\nPY\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle5/local-lean-3.log'"
}
shell output · exit 0
/work/Model.lean:109:37: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:113:34: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:109:37: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/Model.lean:113:34: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/Model.lean:160:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:160:8: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:160:8: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
/work/Model.lean:299:6: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:299:6: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
shell input
{
  "command": "/usr/bin/bash -lc 'python /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json > /work/evidence/cycle5/check-1.txt 2>&1'"
}
assistant
The revised proof compiles locally. It derives positive total heat capacity and feasible liquid temperatures, then proves that immediate addition minimizes boiling time within the calibrated model. The protocol check is now running to verify extraction and the proof independently.
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle5/check-1.txt'"
}
shell output · exit 0
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle5/check-1.txt'"
}
shell output · exit 0
{
 "file": "/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted.lean",
 "conclusions": [
  "nacl_immediate_addition_answer"
 ],
 "lean_exit": 0,
 "ok": false,
 "compiles_alone": true,
 "faithful": {
  "nacl_immediate_addition_answer": false
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
  "heatingTime",
  "boilingTime",
  "naclRelativeEnthalpy",
  "naclDissolutionAt20",
  "naclCapacityChange"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "nacl_immediate_addition_answer": {
   "original_sha256": "4e059ba84be9fa10ef939429ca167e908bb4f196d306821104c392df61665d10",
   "extracted_sha256": "4c241a5c8960d925ed2013b00b4ee9f007e5044394f6d56c95f3cca60ffc18c7"
  }
 },
 "dependency_faithful": {
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "naclCapacityChange": true,
  "naclRelativeEnthalpy._proof_1": true,
  "naclCapacityChange._proof_1": true,
  "naclCapacityChange._proof_2": true,
  "naclCapacityChange._proof_3": true,
  "naclCapacityChange._proof_4": true,
  "naclRelativeEnthalpy": true,
  "naclRelativeEnthalpy._proof_2": true,
  "naclRelativeEnthalpy._proof_3": true,
  "naclRelativeEnthalpy._proof_4": true,
  "naclDissolutionAt20": true,
  "naclDissolutionAt20._proof_1": true,
  "naclDissolutionAt20._proof_2": true,
  "naclDissolutionAt20._proof_3": true,
  "naclCapacityChange._proof_5": true,
  "mixedTemperature": true,
  "netPower": true,
  "boilingTime": true,
  "heatingTime": true
 },
 "dependency_identities": {
  "initialTemperature": {
   "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
   "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
  },
  "initialTemperature._proof_1": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "naclCapacityChange": {
   "original_sha256": "8670a93d0602bcf463a61fee28b4b0132903fa86b5e02063d783a457e0e20d95",
   "extracted_sha256": "8670a93d0602bcf463a61fee28b4b0132903fa86b5e02063d783a457e0e20d95"
  },
  "naclRelativeEnthalpy._proof_1": {
   "original_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e",
   "extracted_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e"
  },
  "naclCapacityChange._proof_1": {
   "original_sha256": "eeb571f066f9fd41079c19239c0556ae7d3640be2b5a3e6c76d862f948944a3d",
   "extracted_sha256": "eeb571f066f9fd41079c19239c0556ae7d3640be2b5a3e6c76d862f948944a3d"
  },
  "naclCapacityChange._proof_2": {
   "original_sha256": "7bb889d46cc76bcb2cc9e5e670df469595a74df8cf7126322071ab7c0be53472",
   "extracted_sha256": "7bb889d46cc76bcb2cc9e5e670df469595a74df8cf7126322071ab7c0be53472"
  },
  "naclCapacityChange._proof_3": {
   "original_sha256": "2ba7335cd3609ac74f89befa6e2bece6c16a746f1305f1fad2a3147c66ccbd9e",
   "extracted_sha256": "2ba7335cd3609ac74f89befa6e2bece6c16a746f1305f1fad2a3147c66ccbd9e"
  },
  "naclCapacityChange._proof_4": {
   "original_sha256": "95a4b8dc8de5704474a04eac7090e59fc6f0dc381b86621ea7b579a8aa989d48",
   "extracted_sha256": "95a4b8dc8de5704474a04eac7090e59fc6f0dc381b86621ea7b579a8aa989d48"
  },
  "naclRelativeEnthalpy": {
   "original_sha256": "241e6415aa135e0478293cafa7224aa561f642e34d34ff566230d5a0769af57e",
   "extracted_sha256": "241e6415aa135e0478293cafa7224aa561f642e34d34ff566230d5a0769af57e"
  },
  "naclRelativeEnthalpy._proof_2": {
   "original_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8",
   "extracted_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8"
  },
  "naclRelativeEnthalpy._proof_3": {
   "original_sha256": "39fafd58592e6f7d4b38f634565fbb6e9bbefe69aeeb93ddf7f184e06209bc4d",
   "extracted_sha256": "39fafd58592e6f7d4b38f634565fbb6e9bbefe69aeeb93ddf7f184e06209bc4d"
  },
  "naclRelativeEnthalpy._proof_4": {
   "original_sha256": "d2b35f180040d865daeefeff1cb2ec8fe91bba9d4feab29fa08cb1cfa9f06a13",
   "extracted_sha256": "d2b35f180040d865daeefeff1cb2ec8fe91bba9d4feab29fa08cb1cfa9f06a13"
  },
  "naclDissolutionAt20": {
   "original_sha256": "707be014e24f264bc42917b6e4b5fd07e07e1ddcc652e798ef1322c03c11d740",
   "extracted_sha256": "707be014e24f264bc42917b6e4b5fd07e07e1ddcc652e798ef1322c03c11d740"
  },
  "naclDissolutionAt20._proof_1": {
   "original_sha256": "d26507b0493f14007ca36940f4f486d4f8a4042b7d1750e0d82a0fc7cd37e327",
   "extracted_sha256": "d26507b0493f14007ca36940f4f486d4f8a4042b7d1750e0d82a0fc7cd37e327"
  },
  "naclDissolutionAt20._proof_2": {
   "original_sha256": "f5c712256be2eb371af21a0efe29a66a19279c2854a6d5728c3b1c27261e70b9",
   "extracted_sha256": "f5c712256be2eb371af21a0efe29a66a19279c2854a6d5728c3b1c27261e70b9"
  },
  "naclDissolutionAt20._proof_3": {
   "original_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae",
   "extracted_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae"
  },
  "naclCapacityChange._proof_5": {
   "original_sha256": "6a4d87025b5494d28bb170c00a0004de722e9ecc9d872d9068b023a8a066c4f0",
   "extracted_sha256": "6a4d87025b5494d28bb170c00a0004de722e9ecc9d872d9068b023a8a066c4f0"
  },
  "mixedTemperature": {
   "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
   "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
  },
  "netPower": {
   "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
   "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
  },
  "boilingTime": {
   "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
   "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
  },
  "heatingTime": {
   "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
   "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "nacl_immediate_addition_answer": "\u2200 (C W k B0 B x : \u211d), 3900 \u2264 C \u2192 0 < k \u2192 99 \u2264 B0 \u2192 B0 \u2264 100.1 \u2192 B0 \u2264 B \u2192 B \u2264 101 \u2192 k * (B - 20) < W \u2192 x \u2208 Set.Icc initialTemperature B0 \u2192 0 < C + naclCapacityChange \u2227 (19 \u2264 mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x \u2227 mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x \u2264 x) \u2227 (0 < netPower W k 20 x \u2227 netPower W k 20 x < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) \u2227 boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature \u2264 boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x"
 },
 "extracted_file": "/work/checks/3366e6e934024e17b8832b7253fbd31c/extracted.lean",
 "errors": []
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:41:59.788687+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/3366e6e934024e17b8832b7253fbd31c/extracted.lean; cat /work/history/cycle1/Model.lean | tail -15; ls /work/diagnostics'"
}
shell output · exit 0
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

def initialTemperature : ℝ := 20

def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80


/-! Conclusions (statements of the proved theorems). -/
def conclusion_nacl_immediate_addition_answer : Prop := ∀ (C W k B0 B x : ℝ), 3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ 100.1 → B0 ≤ B → B ≤ 101 → k * (B - 20) < W → x ∈ Set.Icc initialTemperature B0 → 0 < C + naclCapacityChange ∧ (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧ (0 < netPower W k 20 x ∧ netPower W k 20 x < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧ boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤ boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
cycle2-check-1.txt
cycle2-compile-1.log
cycle2-compile-2.log
cycle2-compile-3.log
cycle2-compile-4.log
cycle3-check-1.txt
cycle3-compile-1.log
cycle3-compile-2.log
cycle3-compile-3.log
extract-trace-1.txt
extract-trace-2.txt
extracted.json
extracted.lean
extraction-result.txt
extraction_trace.py
probe.lean
probe.log
probe2.lean
probe2.log
assistant
The protocol check found that the proof compiles, but the extracted conclusion failed its exact identity comparison. All model definitions matched; I’ll replace the decimal bound in the theorem with the equivalent explicit fraction and rerun the check.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean';s=open(p).read().replace('0 < k → 99 ≤ B0 → B0 ≤ 100.1 →','0 < k → 99 ≤ B0 → B0 ≤ (1001 / 10 : ℝ) →');open(p,'w').write(s)\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json > /work/evidence/cycle5/check-2.txt 2>&1\""
}
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/evidence/cycle5/revision-trace.txt <<'EOF'\nCycle 5 lineage, 2026-11-17 UTC\n\nReviewed supplied human feedback and cycle-3 accepted mathematical check (8ce875bbeedf40f384474d008e4dfa66), as well as the older preserved extraction failure f49ea96bd5de45babf8f3c699ba15e09. Cycle-3 scientific answer remained rejected. Incorporated operator material response f7c987a52391410bb035542305825b3f and read its original source text/PDF bundle; no previous solution or external agent was consulted.\n\nKept the previously selected 10 g dry crystalline NaCl case. Calibrated a 20-to-100 C effective enthalpy secant from the supplied dissolution enthalpies and concentration correction. Disclosed concentration interpolation, standard-enthalpy extrapolation, solid Cp approximation, affine approximation and apparatus conditions. Computed sampled residuals; did not reinterpret them as uniform validation. Retained the generic signed-capacity timing theorem and energy derivations, added one direct physical-case conclusion.\n\nLocal command local-lean-1.log records a wrong guessed executable location, then local-lean-2.log records actual parsing/layout and rewriting errors. The final let binding needed a semicolon so the unary-minus body could not be parsed as continued subtraction; the mixed-temperature lower-bound proof needed rewriting the initial-temperature definition in the goal as well as its hypothesis. No mathematical assumption changed in these repairs. local-lean-3.log subsequently compiled without errors (warnings are retained).\n\nProtocol check 1: checks/3366e6e934024e17b8832b7253fbd31c; lean_exit=0, standalone extraction compiles, every model dependency faithful, but final conclusion identity false. Raw result is check-1.txt. Replaced only the theorem's scientific decimal 100.1 by the exactly equivalent (1001 / 10 : real) to avoid generated proof identity differences during pretty-print extraction; no model or physical bound changed. Protocol check 2 is recorded separately in check-2.txt. Its actual verdict, not local compilation, determines verification status. No human approval is inferred.\nEOF\""
}
shell output · exit 0
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'tail -20 /work/evidence/cycle5/check-2.txt'"
}
shell output · exit 0
   "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "nacl_immediate_addition_answer": "\u2200 (C W k B0 B x : \u211d), 3900 \u2264 C \u2192 0 < k \u2192 99 \u2264 B0 \u2192 B0 \u2264 1001 / 10 \u2192 B0 \u2264 B \u2192 B \u2264 101 \u2192 k * (B - 20) < W \u2192 x \u2208 Set.Icc initialTemperature B0 \u2192 0 < C + naclCapacityChange \u2227 (19 \u2264 mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x \u2227 mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x \u2264 x) \u2227 (0 < netPower W k 20 x \u2227 netPower W k 20 x < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) \u2227 boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature \u2264 boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x"
 },
 "extracted_file": "/work/checks/fa26349a1ab0402c9d16ff1354b2240b/extracted.lean",
 "errors": []
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:42:43.075074+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
shell input
{
  "command": "/usr/bin/bash -lc 'head -45 /work/evidence/cycle5/check-2.txt; cat /work/diagnostics/extract-trace-2.txt | head -40; cat /work/diagnostics/extraction_trace.py | head -100; cat /work/checks/fa26349a1ab0402c9d16ff1354b2240b/extracted.json | head -35'"
}
shell output · exit 0
{
 "file": "/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean",
 "conclusions": [
  "nacl_immediate_addition_answer"
 ],
 "lean_exit": 0,
 "ok": false,
 "compiles_alone": true,
 "faithful": {
  "nacl_immediate_addition_answer": false
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
  "heatingTime",
  "boilingTime",
  "naclRelativeEnthalpy",
  "naclDissolutionAt20",
  "naclCapacityChange"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "nacl_immediate_addition_answer": {
   "original_sha256": "1dbbe717d67817b2f3e3defff7e9952afdf718ce009999ce15cd2b24c79802da",
   "extracted_sha256": "b20c4e1a95de002a09dd15b7c024f69e007ea6ba8e701c2ac60aed1b01e7cec5"
  }
 },
 "dependency_faithful": {
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "naclCapacityChange": true,
  "naclRelativeEnthalpy._proof_1": true,
  "naclCapacityChange._proof_1": true,
  "naclCapacityChange._proof_2": true,
  "naclCapacityChange._proof_3": true,
  "naclCapacityChange._proof_4": true,
  "naclRelativeEnthalpy": true,
  "naclRelativeEnthalpy._proof_2": true,
  "naclRelativeEnthalpy._proof_3": true,
  "naclRelativeEnthalpy._proof_4": true,
  "naclDissolutionAt20": true,
  "naclDissolutionAt20._proof_1": true,
  "naclDissolutionAt20._proof_2": true,
  "naclDissolutionAt20._proof_3": true,
/work/diagnostics/extracted.check.lean:1:0: warning: 
'Mathlib.Data.Real.Basic' has been deprecated: please replace this import by

import Mathlib.Basic.Real.Basic
VAS_EXTRACTED conclusion_addition_timing_answer : ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
  0 < C →
    0 ≤ S →
      0 < P →
        0 < Q →
          HeatBalance C S H Ts B P Q r →
            HeatBalance C S H Ts B P Q s →
              r.x < s.x →
                (r.t < s.t ↔ P < Q) ∧
                  (s.t < r.t ↔ Q < P) ∧
                    (s.t = r.t ↔ Q = P) ∧ (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) VAS_END
VAS_EXTRACTED_IDENTITY conclusion_addition_timing_answer : Lean.Expr.forallE
  Lean.Name.anonymous
  (Lean.Expr.const `Real [])
  (Lean.Expr.forallE
    Lean.Name.anonymous
    (Lean.Expr.const `Real [])
    (Lean.Expr.forallE
      Lean.Name.anonymous
      (Lean.Expr.const `Real [])
      (Lean.Expr.forallE
        Lean.Name.anonymous
        (Lean.Expr.const `Real [])
        (Lean.Expr.forallE
          Lean.Name.anonymous
          (Lean.Expr.const `Real [])
          (Lean.Expr.forallE
            Lean.Name.anonymous
            (Lean.Expr.const `Real [])
            (Lean.Expr.forallE
              Lean.Name.anonymous
              (Lean.Expr.const `Real [])
              (Lean.Expr.forallE
                Lean.Name.anonymous
                (Lean.Expr.const `HeatingRun [])
                (Lean.Expr.forallE
import sys
from pathlib import Path
sys.path.insert(0, '/harness/src')
import vcs_extract
original = vcs_extract.run_lean
counter = 0
def traced(path):
    global counter
    counter += 1
    status, text = original(path)
    Path(f'/work/diagnostics/extract-trace-{counter}.txt').write_text(text)
    return status, text
vcs_extract.run_lean = traced
vcs_extract.main(args=['/work/Model.lean', '--theorem', 'addition_timing_answer', '--out', '/work/diagnostics/extracted'], standalone_mode=False)
{
 "file": "/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean",
 "conclusions": [
  "nacl_immediate_addition_answer"
 ],
 "lean_exit": 0,
 "ok": false,
 "compiles_alone": true,
 "faithful": {
  "nacl_immediate_addition_answer": false
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
  "heatingTime",
  "boilingTime",
  "naclRelativeEnthalpy",
  "naclDissolutionAt20",
  "naclCapacityChange"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "nacl_immediate_addition_answer": {
   "original_sha256": "1dbbe717d67817b2f3e3defff7e9952afdf718ce009999ce15cd2b24c79802da",
   "extracted_sha256": "b20c4e1a95de002a09dd15b7c024f69e007ea6ba8e701c2ac60aed1b01e7cec5"
  }
 },
 "dependency_faithful": {
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "naclCapacityChange": true,
  "naclRelativeEnthalpy._proof_1": true,
  "naclCapacityChange._proof_1": true,
  "naclCapacityChange._proof_2": true,
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/evidence/cycle5/trace_extraction.py <<'PY'\nimport sys\nfrom pathlib import Path\nsys.path.insert(0,'/harness/src')\nimport vcs_extract\noriginal=vcs_extract.run_lean\ncounter=0\ndef traced(path):\n    global counter\n    counter+=1\n    status,text=original(path)\n    Path(f'/work/evidence/cycle5/extract-trace-{counter}.txt').write_text(text)\n    return status,text\nvcs_extract.run_lean=traced\nvcs_extract.main(args=['/work/Model.lean','--theorem','nacl_immediate_addition_answer','--out','/work/evidence/cycle5/trace-extracted'],standalone_mode=False)\nPY\npython /work/evidence/cycle5/trace_extraction.py > /work/evidence/cycle5/trace-extraction-result.txt 2>&1\""
}
shell input
{
  "command": "/usr/bin/bash -lc 'ls -l /work/evidence/cycle5/extract-trace*; tail -8 /work/evidence/cycle5/trace-extraction-result.txt'"
}
shell output · exit 0
-rw-r--r-- 1 1001 1001 162738 Nov 17 23:43 /work/evidence/cycle5/extract-trace-1.txt
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc \"grep -n 'VAS_.*IDENTITY' /work/evidence/cycle5/extract-trace-1.txt | head; grep -n 'VAS_.*IDENTITY' /work/evidence/cycle5/extract-trace-2.txt | head\""
}
shell output · exit 0
45:VAS_ORIGINAL_IDENTITY nacl_immediate_addition_answer : Lean.Expr.forallE
1016:VAS_DEPENDENCY_IDENTITY initialTemperature : definition|levels=[]|type=Lean.Expr.const `Real []|value=Lean.Expr.app
1028:VAS_DEPENDENCY_IDENTITY initialTemperature._proof_1 : theorem|levels=[]|type=Lean.Expr.app
1054:VAS_DEPENDENCY_IDENTITY naclCapacityChange : definition|levels=[]|type=Lean.Expr.const `Real []|value=Lean.Expr.app
1420:VAS_DEPENDENCY_IDENTITY naclRelativeEnthalpy._proof_1 : theorem|levels=[]|type=Lean.Expr.app
1446:VAS_DEPENDENCY_IDENTITY naclCapacityChange._proof_1 : theorem|levels=[]|type=Lean.Expr.app
1472:VAS_DEPENDENCY_IDENTITY naclCapacityChange._proof_2 : theorem|levels=[]|type=Lean.Expr.app
1498:VAS_DEPENDENCY_IDENTITY naclCapacityChange._proof_3 : theorem|levels=[]|type=Lean.Expr.app
1524:VAS_DEPENDENCY_IDENTITY naclCapacityChange._proof_4 : theorem|levels=[]|type=Lean.Expr.app
1550:VAS_DEPENDENCY_IDENTITY naclRelativeEnthalpy : definition|levels=[]|type=Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.const `Real []) (Lean.Expr.const `Real []) (Lean.BinderInfo.default)|value=Lean.Expr.lam
18:VAS_EXTRACTED_IDENTITY conclusion_nacl_immediate_addition_answer : Lean.Expr.forallE
621:VAS_EXTRACTED_DEPENDENCY_IDENTITY initialTemperature : definition|levels=[]|type=Lean.Expr.const `Real []|value=Lean.Expr.app
632:VAS_EXTRACTED_DEPENDENCY_IDENTITY initialTemperature._proof_1 : theorem|levels=[]|type=Lean.Expr.app
657:VAS_EXTRACTED_DEPENDENCY_IDENTITY naclCapacityChange : definition|levels=[]|type=Lean.Expr.const `Real []|value=Lean.Expr.app
1022:VAS_EXTRACTED_DEPENDENCY_IDENTITY naclRelativeEnthalpy._proof_1 : theorem|levels=[]|type=Lean.Expr.app
1047:VAS_EXTRACTED_DEPENDENCY_IDENTITY naclCapacityChange._proof_1 : theorem|levels=[]|type=Lean.Expr.app
1072:VAS_EXTRACTED_DEPENDENCY_IDENTITY naclCapacityChange._proof_2 : theorem|levels=[]|type=Lean.Expr.app
1097:VAS_EXTRACTED_DEPENDENCY_IDENTITY naclCapacityChange._proof_3 : theorem|levels=[]|type=Lean.Expr.app
1122:VAS_EXTRACTED_DEPENDENCY_IDENTITY naclCapacityChange._proof_4 : theorem|levels=[]|type=Lean.Expr.app
1147:VAS_EXTRACTED_DEPENDENCY_IDENTITY naclRelativeEnthalpy : definition|levels=[]|type=Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.const `Real []) (Lean.Expr.const `Real []) (Lean.BinderInfo.default)|value=Lean.Expr.lam
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport re,difflib\nfrom pathlib import Path\na=Path('/work/evidence/cycle5/extract-trace-1.txt').read_text().split('VAS_ORIGINAL_IDENTITY nacl_immediate_addition_answer : ',1)[1].split(' VAS_END',1)[0]\nb=Path('/work/evidence/cycle5/extract-trace-2.txt').read_text().split('VAS_EXTRACTED_IDENTITY conclusion_nacl_immediate_addition_answer : ',1)[1].split(' VAS_END',1)[0]\naa=a.split();bb=b.split()\nfor tag,i,j,k,l in difflib.SequenceMatcher(None,aa,bb,autojunk=False).get_opcodes():\n if tag\"'!='\"'equal':\n  print(tag, '\\\\nORIGINAL:', ' '.join(aa[max(0,i-10):min(len(aa),j+10)]), '\\\\nEXTRACTED:', ' '.join(bb[max(0,k-10):min(len(bb),l+10)]))\nPath('/work/evidence/cycle5/original-conclusion-repr.txt').write_text(a)\nPath('/work/evidence/cycle5/extracted-conclusion-repr.txt').write_text(b)\nPY\""
}
shell output · exit 0
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 3900))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 3900))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_1 [])))) (Lean.Expr.bvar 5)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 3900))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 3899))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 3899))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 3898))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 3898))))))))) (Lean.Expr.bvar 5)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LT.lt 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 3900))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_1 [])))) (Lean.Expr.bvar 5)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LT.lt
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 99))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 99))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_2 [])))) (Lean.Expr.bvar 4)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 99))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 98))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 98))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 97))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 97))))))))) (Lean.Expr.bvar 4)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LE.le 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 99))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_2 [])))) (Lean.Expr.bvar 4)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LE.le
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 1001))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 1001))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_3 [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 1001))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 1000))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 1000))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 999))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 999))))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 1001))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_3 [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 10))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 10))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `naclRelativeEnthalpy._proof_1 []))))) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 10))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 9))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 9))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 8))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 8)))))))))) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LE.le [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 10))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `naclRelativeEnthalpy._proof_1 []))))) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LE.le [Lean.Level.zero]) (Lean.Expr.const
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 101))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 101))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_4 [])))) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 101))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 100))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 100))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 99))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 99))))))))) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LT.lt [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 101))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_4 [])))) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LT.lt [Lean.Level.zero]) (Lean.Expr.const
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))))) (Lean.Expr.bvar 10)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))))) (Lean.Expr.bvar 10)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))))) (Lean.Expr.bvar 10)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_5 [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `mixedTemperature
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 17))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 17))))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `mixedTemperature []) (Lean.Expr.bvar 13)) 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `conclusion_nacl_immediate_addition_answer._proof_5 [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `mixedTemperature []) (Lean.Expr.bvar 13))
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LE.le [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LE.le [Lean.Level.zero]) (Lean.Expr.const
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.bvar 8))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `And []) (Lean.Expr.app 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `And []) (Lean.Expr.app
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LT.lt [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8)))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LT.lt [Lean.Level.zero]) (Lean.Expr.const
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.bvar 8))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `netPower []) (Lean.Expr.bvar 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `netPower []) (Lean.Expr.bvar
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `mixedTemperature
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `mixedTemperature []) (Lean.Expr.bvar 13)) 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `mixedTemperature []) (Lean.Expr.bvar 13))
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8)))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.bvar 8)))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LE.le [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8)))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `LE.le [Lean.Level.zero]) (Lean.Expr.const
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 9)) (Lean.Expr.bvar 12)) (Lean.Expr.bvar 11)) (Lean.Expr.app
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.bvar 9)) (Lean.Expr.bvar 12)) (Lean.Expr.bvar 11)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 9)) (Lean.Expr.bvar 12)) (Lean.Expr.bvar 11)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.const `initialTemperature []))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.const `initialTemperature []))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.const `initialTemperature []))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 9)) (Lean.Expr.bvar 12)) (Lean.Expr.bvar 11)) (Lean.Expr.app
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.bvar 9)) (Lean.Expr.bvar 12)) (Lean.Expr.bvar 11)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 9)) (Lean.Expr.bvar 12)) (Lean.Expr.bvar 11)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const
delete 
ORIGINAL: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const 
EXTRACTED: [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8)))))) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default))
replace 
ORIGINAL: [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.instAtLeastTwoHAddOfNat []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19))))) (Lean.Expr.app (Lean.Expr.const `Nat.instNeZeroSucc []) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 18))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 18))))))))) (Lean.Expr.bvar 8)))))) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) 
EXTRACTED: (Lean.Expr.const `Real [])) (Lean.Expr.lit (Lean.Literal.natVal 20))) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.const `initialTemperature._proof_1 [])))) (Lean.Expr.bvar 8)))))) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default))
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean';s=open(p).read();a=s.index('theorem nacl_immediate_addition_answer :');b=s.index(' := by',a);statement=s[a:b]\nimport re\nstatement=re.sub(r'\\\\b(3900|99|1001|10|101|19|20)\\\\b',lambda m:'initialTemperature' if m[0]=='20' else '(('+m[0]+' : ℕ) : ℝ)',statement)\ns=s[:a]+statement+s[b:];open(p,'w').write(s)\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json > /work/evidence/cycle5/check-3.txt 2>&1\""
}
shell output · exit 1 · failed
assistant
The extraction traces identify the mismatch in Lean’s hidden proof terms for numeric literals. I’ve changed how those constants are written, preserving their values, and am rerunning the protocol check. The scientific model and conclusion are unchanged.
shell input
{
  "command": "/usr/bin/bash -lc 'tail -20 /work/evidence/cycle5/check-3.txt'"
}
shell output · exit 0
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:44:19.408976+00:00",
  "lean_exit": 1,
  "error": "Lean, kernel recheck or axiom audit failed; see lean.log"
}
shell input
{
  "command": "/usr/bin/bash -lc 'find /work/checks -name lean.log -mmin -2 -print'"
}
shell output · exit 0
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/lean.log
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/lean.log
shell input
{
  "command": "/usr/bin/bash -lc 'tail -100 /work/checks/45e3bdc1f6974c4dae446c78777c9f79/lean.log'"
}
shell output · exit 0
                    (Mathlib.Tactic.Ring.Common.mul_add
                      (Mathlib.Tactic.Ring.Common.mul_pf_left k (Nat.rawCast 1)
                        (Mathlib.Tactic.Ring.Common.mul_pf_right B (Nat.rawCast 1)
                          (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                            (Mathlib.Meta.NormNum.IsInt.to_isNat
                              (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1)) (Eq.refl (Int.ofNat 1)))))))
                      (Mathlib.Tactic.Ring.Common.mul_add
                        (Mathlib.Tactic.Ring.Common.mul_pf_left k (Nat.rawCast 1)
                          (Mathlib.Tactic.Ring.Common.mul_pf_right B0 (Nat.rawCast 1)
                            (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                              (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                (Eq.refl (Int.negOfNat 1))))))
                        (Mathlib.Tactic.Ring.Common.mul_zero (k ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast))
                        (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                          (k ^ Nat.rawCast 1 * (B0 ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast) + 0)))
                      (Mathlib.Tactic.Ring.Common.add_pf_add_lt
                        (k ^ Nat.rawCast 1 * (B ^ Nat.rawCast 1 * Nat.rawCast 1))
                        (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                          (k ^ Nat.rawCast 1 * (B0 ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast) + 0))))
                    (Mathlib.Tactic.Ring.Common.zero_mul
                      (B ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + (B0 ^ Nat.rawCast 1 * Nat.rawCast 1 + 0)))
                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                      (k ^ Nat.rawCast 1 * (B ^ Nat.rawCast 1 * Nat.rawCast 1) +
                        (k ^ Nat.rawCast 1 * (B0 ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast) + 0)))))
                (Mathlib.Tactic.Ring.Common.sub_pf
                  (Mathlib.Tactic.Ring.Common.neg_add
                    (Mathlib.Tactic.Ring.Common.neg_mul k (Nat.rawCast 1)
                      (Mathlib.Tactic.Ring.Common.neg_mul B (Nat.rawCast 1)
                        (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                          (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                            (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                            (Eq.refl (Int.negOfNat 1))))))
                    (Mathlib.Tactic.Ring.Common.neg_add
                      (Mathlib.Tactic.Ring.Common.neg_mul k (Nat.rawCast 1)
                        (Mathlib.Tactic.Ring.Common.neg_mul B0 (Nat.rawCast 1)
                          (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                            (Mathlib.Meta.NormNum.IsInt.to_isNat
                              (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1)) (Eq.refl (Int.ofNat 1)))))))
                      Mathlib.Tactic.Ring.Common.neg_zero))
                  (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                    (k ^ Nat.rawCast 1 * (B ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast) +
                      (k ^ Nat.rawCast 1 * (B0 ^ Nat.rawCast 1 * Nat.rawCast 1) + 0)))))
              (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero k (Nat.rawCast 1)
                  (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero B (Nat.rawCast 1)
                    (Mathlib.Meta.NormNum.IsInt.to_isNat
                      (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                        (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                        (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1)) (Eq.refl (Int.ofNat 0))))))
                (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                  (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero k (Nat.rawCast 1)
                    (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero B0 (Nat.rawCast 1)
                      (Mathlib.Meta.NormNum.IsInt.to_isNat
                        (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                          (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                          (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                          (Eq.refl (Int.ofNat 0))))))
                  (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0))))
            (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))))
        (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
          (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le (Mathlib.Tactic.Linarith.sub_neg_of_lt hpowB)
            (Mathlib.Tactic.Linarith.sub_nonpos_of_le a))
          (Mathlib.Tactic.Linarith.sub_nonpos_of_le
            (mul_nonneg_of_nonpos_of_nonpos (le_of_lt (Mathlib.Tactic.Linarith.sub_neg_of_lt hk))
              (Mathlib.Tactic.Linarith.sub_nonpos_of_le
                hB))))))) (hdomain : initialTemperature ≤
  B0 := sorry) (hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤
  B := le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl B0⟩))
  hB) (feasible : (initialTemperature ≤ x ∧ x ≤ B0) ∧
  (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ B) ∧
    0 < netPower W k 20 x ∧
      0 <
        netPower W k 20
          (mixedTemperature C naclCapacityChange naclDissolutionAt20 20
            x) := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20 19 B0 initialTemperature B0 x
  hc0 hc hk
  (Eq.mpr (id (congrArg (fun _a => 19 ≤ _a) hi))
    (Mathlib.Meta.NormNum.isNat_le_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 19))
      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 20)) (Eq.refl true)))
  (le_refl initialTemperature) hdomain (le_refl B0) hz19 hzB hpow0 hpowB
  hx) (hj : netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x =
  k * (naclCapacityChange * (x - 20) + naclDissolutionAt20) /
    (C +
      naclCapacityChange) := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x
  (ne_of_gt
    hc)) (hjpos : 0 <
  netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) -
    netPower W k 20
      x := Eq.mpr (id (congrArg (fun _a => 0 < _a) hj))
  (div_pos (mul_pos hk (hcool x hx))
    hc)) ⊢ netPower W k initialTemperature x <
  netPower W k initialTemperature
    (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x) VAS_END
VAS_LISTED
shell input
{
  "command": "/usr/bin/bash -lc \"grep -n -A 12 'error:' /work/checks/45e3bdc1f6974c4dae446c78777c9f79/lean.log | head -75\""
}
shell output · exit 0
28:/work/checks/45e3bdc1f6974c4dae446c78777c9f79/Checked.lean:388:45: error: linarith failed to find a contradiction
29-C W k B0 B x : ℝ
30-hC : ↑3900 ≤ C
31-hk : 0 < k
32-hBlo : ↑99 ≤ B0
33-hBhi : B0 ≤ ↑1001 / ↑10
34-hB : B0 ≤ B
35-hBmax : B ≤ ↑101
36-hW : k * (B - initialTemperature) < W
37-hx : x ∈ Set.Icc initialTemperature B0
38-hHlo : 810 ≤ naclDissolutionAt20
39-hHhi : naclDissolutionAt20 ≤ 820
40-hSlo : -9 ≤ naclCapacityChange
--
45:/work/checks/45e3bdc1f6974c4dae446c78777c9f79/Checked.lean:407:4: error: linarith failed to find a contradiction
46-C W k B0 B x : ℝ
47-hC : ↑3900 ≤ C
48-hk : 0 < k
49-hBlo : ↑99 ≤ B0
50-hBhi : B0 ≤ ↑1001 / ↑10
51-hB : B0 ≤ B
52-hBmax : B ≤ ↑101
53-hW : k * (B - initialTemperature) < W
54-hx : x ∈ Set.Icc initialTemperature B0
55-hHlo : 810 ≤ naclDissolutionAt20
56-hHhi : naclDissolutionAt20 ≤ 820
57-hSlo : -9 ≤ naclCapacityChange
--
70:/work/checks/45e3bdc1f6974c4dae446c78777c9f79/Checked.lean:408:60: error: linarith failed to find a contradiction
71-C W k B0 B x : ℝ
72-hC : ↑3900 ≤ C
73-hk : 0 < k
74-hBlo : ↑99 ≤ B0
75-hBhi : B0 ≤ ↑1001 / ↑10
76-hB : B0 ≤ B
77-hBmax : B ≤ ↑101
78-hW : k * (B - initialTemperature) < W
79-hx : x ∈ Set.Icc initialTemperature B0
80-hHlo : 810 ≤ naclDissolutionAt20
81-hHhi : naclDissolutionAt20 ≤ 820
82-hSlo : -9 ≤ naclCapacityChange
--
93:/work/checks/45e3bdc1f6974c4dae446c78777c9f79/Checked.lean:412:56: error: linarith failed to find a contradiction
94-C W k B0 B x : ℝ
95-hC : ↑3900 ≤ C
96-hk : 0 < k
97-hBlo : ↑99 ≤ B0
98-hBhi : B0 ≤ ↑1001 / ↑10
99-hB : B0 ≤ B
100-hBmax : B ≤ ↑101
101-hW : k * (B - initialTemperature) < W
102-hx : x ∈ Set.Icc initialTemperature B0
103-hHlo : 810 ≤ naclDissolutionAt20
104-hHhi : naclDissolutionAt20 ≤ 820
105-hSlo : -9 ≤ naclCapacityChange
--
118:/work/checks/45e3bdc1f6974c4dae446c78777c9f79/Checked.lean:423:24: error: linarith failed to find a contradiction
119-C W k B0 B x : ℝ
120-hC : ↑3900 ≤ C
121-hk : 0 < k
122-hBlo : ↑99 ≤ B0
123-hBhi : B0 ≤ ↑1001 / ↑10
124-hB : B0 ≤ B
125-hBmax : B ≤ ↑101
126-hW : k * (B - initialTemperature) < W
127-hx : x ∈ Set.Icc initialTemperature B0
128-hHlo : 810 ≤ naclDissolutionAt20
129-hHhi : naclDissolutionAt20 ≤ 820
130-hSlo : -9 ≤ naclCapacityChange
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean';s=open(p).read().replace('  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx\\\\n','  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx\\\\n  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢\\\\n  dsimp only [initialTemperature] at hW ⊢\\\\n');open(p,'w').write(s)\nPY\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle5/local-lean-4.log 2>&1\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"grep -n -A 8 'error:' /work/evidence/cycle5/local-lean-4.log\""
}
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'python /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json > /work/evidence/cycle5/check-4.txt 2>&1'"
}
shell input
{
  "command": "/usr/bin/bash -lc \"cat >> /work/evidence/cycle5/revision-trace.txt <<'EOF'\n\nProtocol check 2 also compiled but failed conclusion identity, so replacing only the decimal was insufficient. Instrumented the installed extractor using the run's pre-existing tracing method, preserving both raw repr traces. Differences identify Real numeric literals' auxiliary proof arguments (original theorem inline, extracted definition lifted). Protocol check 3 replaced all >=2 Real literals in the public theorem with exact natural-to-real casts and reused initialTemperature=20. It then reported real proof elaboration errors in lean.log because arithmetic tactics did not normalize those casts/temperature references automatically. Added proof-local normalization of casts and initialTemperature only. local-lean-4.log compiles this revised proof successfully. Protocol check 4 records the actual independent result. No scientific bound, assumption, data point or conclusion changed during these representation repairs.\nEOF\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'tail -15 /work/evidence/cycle5/check-4.txt'"
}
shell output · exit 0
assistant
The full proof compiles with the revised numeric notation. The remaining scientific limitation is explicit in the report: the timing result depends on an effective enthalpy fit with a short extrapolation toward 100 °C; the supplied data do not certify its accuracy across the full temperature range.
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'tail -15 /work/evidence/cycle5/check-4.txt'"
}
shell output · exit 0
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "nacl_immediate_addition_answer": "\u2200 (C W k B0 B x : \u211d), \u21913900 \u2264 C \u2192 0 < k \u2192 \u219199 \u2264 B0 \u2192 B0 \u2264 \u21911001 / \u219110 \u2192 B0 \u2264 B \u2192 B \u2264 \u2191101 \u2192 k * (B - initialTemperature) < W \u2192 x \u2208 Set.Icc initialTemperature B0 \u2192 0 < C + naclCapacityChange \u2227 (\u219119 \u2264 mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x \u2227 mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x \u2264 x) \u2227 (0 < netPower W k initialTemperature x \u2227 netPower W k initialTemperature x < netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) \u2227 boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature \u2264 boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x"
    },
    "extracted_file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/0a52ddc3554b4e10b6c5b477fceb0093/verdict.json | head -24; head -15 /work/evidence/cycle5/check-4.txt'"
}
shell output · exit 0
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T23:45:21.072186+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean",
    "conclusions": [
      "nacl_immediate_addition_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "nacl_immediate_addition_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
{
 "file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean",
 "conclusions": [
  "nacl_immediate_addition_answer"
 ],
 "lean_exit": 0,
 "ok": true,
 "compiles_alone": true,
 "faithful": {
  "nacl_immediate_addition_answer": true
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
assistant
For the modeled case of **10 g NaCl initially at 20 °C**, the result is **add it immediately, at 20 °C**. This depends on the documented effective heat-capacity model and shared Newtonian heat-loss law. The original unspecified setup does not determine a universal answer or heating time.

The revised Lean proof passed compilation, faithful extraction, and kernel checking. Its empirical approximations still require human review; no human acceptance is claimed.

[Report and assumptions](/work/report.txt) · [Lean proof](/work/Model.lean) · [Check result](/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/verdict.json)

Produced code

attempt-004/Model.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢
  dsimp only [initialTemperature] at hW ⊢
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
attempt-004/extracted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

def initialTemperature : ℝ := 20

def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80


/-! Conclusions (statements of the proved theorems). -/
def conclusion_nacl_immediate_addition_answer : Prop := ∀ (C W k B0 B x : ℝ), ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) → B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W → x ∈ Set.Icc initialTemperature B0 → 0 < C + naclCapacityChange ∧ (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧ (0 < netPower W k initialTemperature x ∧ netPower W k initialTemperature x < netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧ boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤ boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x
checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢
  dsimp only [initialTemperature] at hW ⊢
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/19e916da3a2f417381acb479d8151af9/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
checks/3366e6e934024e17b8832b7253fbd31c/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ 100.1 →
    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧
    (0 < netPower W k 20 x ∧
      netPower W k 20 x <
        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/45e3bdc1f6974c4dae446c78777c9f79/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ (1001 / 10 : ℝ) →
    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧
    (0 < netPower W k 20 x ∧
      netPower W k 20 x <
        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)

Round 6

Messages

assistant
I’ll review the previous proof, diagnostics, and source material, focusing on the temperature-dependent enthalpy model and the gaps identified by the human review.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work'"
}
shell output · exit 0
total 108
drwxrwxr-x  8 1001 1001  4096 Nov 17 23:57 .
drwxr-xr-x  1 root root  4096 Nov 17 23:58 ..
-rw-r--r--  1 1001 1001 21006 Nov 17 23:45 Model.lean
-rw-r--r--  1 1001 1001  4229 Nov 17 23:41 candidate.json
drwxr-xr-x 11 1001 1001  4096 Nov 17 23:45 checks
drwxr-xr-x  2 1001 1001  4096 Nov 17 15:48 diagnostics
drwxr-xr-x  4 1001 1001  4096 Nov 17 23:37 evidence
drwxr-xr-x  6 1001 1001  4096 Nov 17 23:37 history
-rw-------  1 1001 1001  5340 Nov 17 23:57 human-feedback.json
drwxrwxr-x  3 1001 1001  4096 Nov 17 23:34 inputs
-rw-------  1 1001 1001 15186 Nov 17 23:47 last-review-packet.json
-rw-r--r--  1 1001 1001   456 Nov 17 14:15 lean-env.sh
-rw-r--r--  1 1001 1001 14551 Nov 17 23:41 report.txt
drwxr-xr-x  2 1001 1001  4096 Nov 17 23:34 requests
shell input
{
  "command": "/usr/bin/bash -lc 'find /work -maxdepth 3 -type f | head -80'"
}
shell output · exit 0
/work/report.txt
/work/human-feedback.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-report.txt
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-candidate.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/lean.log
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted-report.txt
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted-candidate.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/lean.log
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/extracted.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/extracted.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/verdict.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/Checked.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-report.txt
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-candidate.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/lean.log
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-report.txt
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-candidate.json
/work/checks/19e916da3a2f417381acb479d8151af9/lean.log
/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.json
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/verdict.json
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted-report.txt
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted-candidate.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/lean.log
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/verdict.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/Checked.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-report.txt
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-candidate.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted-report.txt
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted-candidate.json
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/lean.log
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted.lean
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/verdict.json
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/Checked.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-report.txt
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-candidate.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/lean.log
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted-report.txt
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted-candidate.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/lean.log
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/extracted.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/extracted.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/verdict.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/Checked.lean
/work/diagnostics/extraction-result.txt
/work/diagnostics/cycle3-compile-1.log
/work/diagnostics/probe2.log
/work/diagnostics/extract-trace-1.txt
/work/diagnostics/cycle3-check-1.txt
/work/diagnostics/cycle2-compile-4.log
/work/diagnostics/cycle2-compile-1.log
/work/diagnostics/cycle2-compile-3.log
/work/diagnostics/probe.log
/work/diagnostics/extraction_trace.py
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/candidate.json; cat /work/checks/fa26349a1ab0402c9d16ff1354b2240b/verdict.json; ls /work/history; ls /work/inputs/material-evidence-001'"
}
shell output · exit 0
{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "nacl_immediate_addition_answer"
  },
  "user_facts": [
    "One litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.",
    "Salt will be added; salt quantity, pot, heater and room conditions otherwise unspecified."
  ],
  "model_choices": [
    "Scenario retained from cycle 4: 10 g pure dry crystalline NaCl held at 20 C before addition; ambient and initially equilibrated pot at 20 C; approximately atmospheric pressure. Nominal solvent mass .99820675 kg from NIST 20 C density and molar mass 58.443 g/mol determine .1714143 mol/kg.",
    "Use published Partanen2023 PI(con) relative enthalpy expression, interpolating its v,q between .15 and .20 mol/kg. Standard solid dissolution enthalpy at 20 C is interpolated from actual 19.97 and 25 C entries in its Table 8. Add same-temperature finite-concentration correction; derive H, do not assume its sign.",
    "Effective constant signed solution-minus-water heat capacity S is the 20-to-100 C apparent-enthalpy secant with solid salt referenced to 20 C. Standard dissolution enthalpy at 100 C is linearly extrapolated from 84.98 and 95.18 C values; solid sensible heat uses effective 51 J/(mol K), guided by NIST-JANAF. Derive S from these inputs, not from a preset sign. This affine effective enthalpy model is used on 19..101 C; it is a reduction, not a uniform local-capacity bound. Sampled residuals are disclosed; extrapolation and uniform physical accuracy have no certified uncertainty bound.",
    "Shared constant-input Newtonian heat flow N(T)=W-k*(T-20), k>0, unchanged by salinity. Heating obeys capacity*dT/dt=N(T); constant water+pot capacity C>=3900 J/K. Affine enthalpies, instantaneous adiabatic complete dissolution, no heating interruption, negligible evaporation and material loss; uniform liquid/pot temperature.",
    "Unsalted boiling B0 satisfies 99<=B0<=100.1 C; final brine boiling satisfies B0<=B<=101 C. Assume enough power W>k*(B-20). Compare all additions 20<=x<=B0, allowing only the onset of unsalted boiling without dwelling. Liquid/solubility applicability is explicit. The proof derives positive final capacity, postmix temperature>=19 C, postmix temperature<=x<=B, and positive heat flow."
  ],
  "sources": [
    "Operator source bundle /work/inputs/material-evidence-001/sources.json, with original PDFs/text and SHA256 hashes; response f7c987a52391410bb035542305825b3f.",
    "https://doi.org/10.1007/s10953-023-01322-y \u2014 Partanen2023 Eqs.13-19 and Tables 2,8; Table 8 attributes standard solid dissolution data to Criss and Cobble.",
    "https://doi.org/10.1007/s10953-024-01412-5 \u2014 Partanen2025 Eqs.9-10,18 and discussion of competing absolute heat-capacity baselines.",
    "https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf \u2014 GLP10 water density.",
    "https://janaf.nist.gov/tables/Cl-055.html \u2014 crystalline NaCl heat capacity.",
    "https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2 \u2014 molar mass and solid correlation validity limits.",
    "https://iapws.org/technical-guidance/release/IAPWS-95 \u2014 pure-water thermal and phase relationships."
  ],
  "incorporated_inputs": [
    "f7c987a52391410bb035542305825b3f"
  ],
  "proof_scope": "For the explicit literature-calibrated effective affine-enthalpy NaCl case, derives signed capacity/dissolution bounds, positive final capacity, feasible liquid mixing temperatures, net-power increase from energy conservation and the shared loss law, and immediate addition as a global minimizer over 20 C through onset of unsalted boiling. Retains signed-capacity and reference-consistent balance derivations, stage-time uniqueness from inverse energy balance, and full-schedule derivative/monotonicity proof. No sorry or additional axiom. Conditional on exposed empirical interpolation/extrapolation, effective constant-capacity reduction, phase and apparatus premises; does not certify their physical accuracy, infer a numerical duration, resolve all unspecified salts/apparatus, or claim human approval. Raw calculations and Lean diagnostics preserved in evidence/cycle5/."
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:42:43.075074+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
cycle1
cycle2
cycle3
cycle5-start
archer-1992-nacl-water-ocr.txt
archer-1992-nacl-water.pdf
archer-1992-nacl-water.txt
archer-preview-01.png
archer-preview-02.png
iapws95-2018.pdf
iapws95-2018.txt
nist-janaf-nacl-solid.html
nist-janaf-nacl-solid.txt
nist-water-density.pdf
nist-water-density.txt
nist-webbook-nacl.html
nist-webbook-nacl.txt
partanen-2023-enthalpy.pdf
partanen-2023-enthalpy.txt
partanen-2025-heat-capacity.pdf
partanen-2025-heat-capacity.txt
sources.json
water-density-evaluation.json
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/Model.lean'"
}
shell output · exit 0
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢
  dsimp only [initialTemperature] at hW ⊢
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/report.txt; cat /work/human-feedback.json; cat /work/checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json; cat /work/checks/cd3bf32329e547d19d474c1bd79431b9/lean.log'"
}
shell output · exit 0
Cycle 5 revision: a literature-calibrated dilute NaCl example

Answer and limits

The original observations do not specify a universal addition temperature or a number of seconds. The salt, amount, salt temperature and heating apparatus affect the answer. For the explicit 10 g dry NaCl example below, the derived effective enthalpy model predicts: add it immediately, at the initial water temperature 20 C (elapsed heating time zero). This is a conditional scientific prediction, not a measurement, and not an unconditional recommendation for every salt or apparatus.

The new theorem nacl_immediate_addition_answer establishes this over the complete scheduling domain from 20 C to the onset of unsalted boiling. It also derives positive final heat capacity, a liquid postmix temperature and the increase in net heating power. It never compares schedules that dwell at unsalted boiling. No seconds or magnitude of time saving is inferred. The inequality establishes a minimizer; it does not formally assert uniqueness.

Supplied information and provenance

The user supplied one litre of water initially at 20 C, a pot and a stove, with the salt quantity, pot, heater and room otherwise unspecified. All other scenario conditions below are researcher choices, not observations of this kitchen.

Earlier cycles: the shared constant-input, Newtonian heat-loss law was accepted as an approximation. Human feedback rejected treating before/after powers as independent, then rejected presuming a nonnegative heat-capacity change, and finally requested a concrete physical case supported by material evidence. The cycle-3 check compiled and independently extracted the signed-capacity theorem (checks/8ce875bbeedf40f384474d008e4dfa66); that mathematical result was not human acceptance of its scientific sufficiency. Older extraction failures and their diagnostics remain in checks/. Cycle 4 requested material literature. This revision incorporates external response f7c987a52391410bb035542305825b3f, whose source bundle is inputs/material-evidence-001/. It supplies primary literature, not a physical experiment or a timing conclusion. Original cycle-5-start files are preserved in history/cycle5-start/.

Concrete scenario and material inference

Choose 10 g pure dry crystalline NaCl stored at 20 C, with the room also at 20 C and approximately atmospheric pressure. This is a modest culinary concentration, chosen before receiving material values in cycle 4 and retained unchanged. NIST GLP10 gives water density at 20 C of 0.99820675 g/cm3 (air-free reference); one reference litre is therefore 0.99820675 kg. Using NIST's NaCl molar mass 58.443 g/mol gives n=10/58.443=0.1711069 mol and m=n/0.99820675=0.1714143 mol/kg. Actual volume, purity and pressure uncertainties were not supplied. These nominal reference conversions are empirical model inputs, not an inference about their experimental precision.

We use finite-concentration enthalpies rather than misidentifying relative apparent capacities as absolute ones. Partanen & Partanen (2023), Table 2, gives PI(con) parameters at molalities 0.15 and 0.20. In units J, mol and K these are:
 m=.15: v=-.8329e-3, q=-60.2e-6;
 m=.20: v=-.0527e-3, q=-73.5e-6.
We linearly interpolate v and q in molality between these two neighboring tabulated compositions. With Celsius t and absolute T=t+273.15, their Eq. 19 (also 2025 Eq. 18) gives the relative apparent molar enthalpy
 L(t)=-(t+273.15)^2 [v+2 q t].
Lean's naclRelativeEnthalpy exposes this exact interpolation. It gives L(20)=269.38 and L(100)=1904.54 J/mol. This empirical interpolation is distinct from directly evaluating the full Hückel model at m; it uses published model outputs, not a newly fitted physical measurement.

For the infinite-dilution isothermal SOLID dissolution enthalpy, Partanen2023 Table 8 reproduces Criss & Cobble: 4481 J/mol at the actual 19.97 C and 3824 at 25 C. Linear interpolation to 20 C gives h_inf(20)=4477.08 J/mol. The finite-concentration isothermal solid dissolution energy is h20=h_inf(20)+L(20)=4746.46 J/mol. The total H=n*h20 is about 812.15 J. It is referenced to dissolution with both solid salt and water at 20 C, not at the later addition temperature. Lean's naclDissolutionAt20 makes this conversion explicit.

We construct an EFFECTIVE CONSTANT heat-capacity change using an enthalpy secant. This is a model reduction, not a claim that local heat capacity is constant. Table 8 gives -3222 J/mol at 84.98 C and -4540 at 95.18 C. Extend this last standard-dissolution segment linearly by 4.82 K to 100 C:
 h_inf(100)=-4540-(100-95.18)*1318/(95.18-84.98).
For the solid sensible enthalpy from 20 to 100 C, use the approximation c_s=51 J/(mol K). NIST-JANAF gives Cp=50.509 at 298.15 K, 50.543 at 300 K, 52.350 at 400 K. Thus 51 is a reasonable effective value for this interval, though it is an explicit approximation; the WebBook Shomate fit starting at 298 K is NOT claimed validated at 293 K. The reference-consistent apparent energy with solid held at 20 C is
 D_mol(t)=h_inf(t)+c_s*(t-20)+L(t).
At 100 C the calculation gives D_mol=821.72 J/mol. Define the effective signed capacity increment by its secant
 s_eff=[D_mol(100)-h20]/80=-49.0593 J/(mol K),
 S=n*s_eff=-8.39438 J/K.
Lean's naclCapacityChange derives this from the source numbers and exposed interpolation choices. It does not assume S>=0, and does not use dissolution-enthalpy slope alone as S: the solid sensible-heat reference conversion is essential.

The affine effective apparent enthalpy is n*[h20+s_eff*(t-20)]. Consequently it honors the calibrated apparent enthalpy at both endpoints. The proof derives the conservative rational bounds 810<=H<=820 J and -9<=S<=-8 J/K from these formulas, rather than adopting those bounds as independent premises.

Why this reduction, and what it does not establish

The accepted lumped model uses constant capacities. Fitting its signed increment to an enthalpy secant preserves the integrated 20-to-100 C energy difference instead of extending a local 25 C capacity over 80 K. As a diagnostic, evaluating D_mol at all nine supplied Criss-Cobble temperatures from 19.97 to 95.18 C and using the same finite-concentration correction gives residuals against this secant between about -192 and +34 J/mol (total absolute discrepancy <=33 J for the chosen amount). The predicted cooling energy at 100 C is about 141 J, so these sampled discrepancies are smaller than its sign margin. This supports the qualitative approximation; it is NOT a certified uniform interpolation error, a new measurement, or a theorem about variable-capacity real brine. Local capacities vary, and the formal answer remains conditional on the affine effective enthalpy model, extended over the used 19-to-101 C interval. The 95.18-to-100 C extrapolation has no newly certified confidence interval. These are independent scientific limitations for human review, not hidden axioms or unreported experimental validation.

We do not combine the 2025 Table 2 absolute capacity baseline -84 J/(mol K) with its alternative Eq.22 baseline -8-2t. The source itself discusses baseline discrepancies for dilute brine. Such mixing would destroy the reference consistency. Here 2025 Eqs.9-10 justify capacity as an enthalpy derivative; the numerical calibration uses the coherent solid-dissolution reference from 2023 plus the stated solid sensible heat.

No probability distribution is needed: this is a deterministic thermodynamic reduction calibrated to published nominal values. The supplied observations cannot identify heater input, heat loss or pot capacity, so no numerical duration is inferred. No prior, synthetic experiment or device measurement has been invented.

Physical model and formal inference

C is the original effective water-plus-pot heat capacity in J/K, with C>=3900. About .9982 kg liquid water has heat capacity roughly 4.2 kJ/K near these temperatures (IAPWS95); a nonnegative equilibrated pot capacity increases this. The lower bound is conservative, but remains a scenario/applicability premise rather than a measured pot property. We retain instantaneous complete dissolution and adiabatic mixing, no heating interruption, negligible evaporation or change of composition, and uniform water/pot temperature. The modest .1714 mol/kg concentration is far below the roughly 6 mol/kg saturation-scale compositions studied in the supplied primary papers. Full dissolution, no transient local phase problem and maintenance of the chosen liquid composition are applicability assumptions. The comparison includes neither evaporation losses nor the time spent pouring or stirring.

The same net heat flow applies before and after salting:
 N(T)=W-k*(T-20), k>0, with constant input W.
No salinity-dependent heat-transfer change is assumed. This is the approximation accepted in earlier feedback. A different real heat-transfer law can alter the result.

Affine enthalpy conservation at addition temperature x gives
 (C+S)*z = C*x+S*20-H,
 z=(C*x+S*20-H)/(C+S).
The previous reference_consistent_balance lemma proves that this is equivalent to heating the solid to x and dissolving there with dissolution heat H+(S-c_s)*(x-20). It uses one reference consistently. S is the full solution-minus-original-water capacity difference, with pot unchanged, and can be negative.

The net-power change is DERIVED, not supplied:
 N(z)-N(x) = k*[H+S*(x-20)]/(C+S).
For this calibrated case the proof derives C+S>0 and H+S*(x-20)>0 for every 20<=x<=B0<=100.1. Indeed the loose material bounds give at least 810-9*80.1=89.1 J. Therefore mixing cools the water and increases its net heating power even though S<0. Lower mixture heat capacity does not by itself determine the sign of the temperature jump.

Heating obeys capacity*dT/dt=N(T). heatingTime is the integrated inverse first law:
 h(K,u,v)=K/k * log[N(u)/N(v)].
The Lean stage_time_from_energy lemma proves that any elapsed-time function with derivative K/N(T) and zero starting time equals this integral, so the final theorem is not just arithmetic on an externally calculated answer. With final brine boiling B, total time is
 tau(x)=h(C,20,x)+h(C+S,z(x),B).
The proof differentiates the ENTIRE schedule, including the mixing jump, and derives
 tau'(x)=C*k*[H+S*(x-20)] / [(C+S)*N(x)*N(z(x))].
Positive powers and capacities make this nonnegative across the whole feasible scheduling domain. A mean-value monotonicity theorem then proves tau(20)<=tau(x). This is the scientific inference behind immediate addition. The generic signed-capacity timing theorem and its derivations from cycle 3 are retained as supporting work.

Domain and apparatus review boundary

The final theorem assumes 99<=B0<=100.1 C, B0<=B<=101 C, and W>k*(B-20). These give a conservative approximately atmospheric liquid boiling domain and sufficient heater power to reach the final endpoint. IAPWS95 supports the pure-water endpoint; the small elevation is physically consistent with dilute NaCl (the leading dilute estimate is approximately 2*0.512*.1714=0.176 K), but those numerical boiling bounds are exposed scenario assumptions, not a formally solved activity/equilibrium model or measured pressure. Only final brine, not unsalted water, is heated above B0.

The comparison domain is exactly 20<=x<=B0. B0 means onset of unsalted boiling, with immediate addition and no dwell. From the material inference and C bound, Lean derives the earliest mixed temperature >=19 C. Monotonicity of z(x) gives the same lower bound throughout. Cooling gives z(x)<=x<=B0<=B. Positive N(B) ensures positive heat flow everywhere on each liquid heating stage. Thus the proof derives the important state and positivity conditions from the case; they are not imported as a long list of unrelated trajectory hypotheses.

Compact review packet

Supplied facts: 1 L initial water at 20 C; unspecified salt/pot/heater/room.

Additional choices: 10 g pure crystalline NaCl at 20 C; room 20 C; nominal density/molar-mass conversion; the explicit published-data interpolation and short standard-enthalpy extrapolation; c_s=51; effective affine enthalpies on 19..101 C; complete instantaneous dissolution and mixing with negligible evaporation; shared constant-input Newtonian losses; C>=3900; the stated approximately atmospheric boiling bounds; heater strong enough to reach B. None is presented as an observed apparatus parameter or as inferred from the user's volume and temperature alone.

Necessary definitions: initialTemperature=20, netPower, mixedTemperature, integrated heatingTime and full boilingTime; naclRelativeEnthalpy, naclDissolutionAt20 and naclCapacityChange contain the complete material calibration. Units and references are stated above and alongside Lean definitions.

Proved conclusion: nacl_immediate_addition_answer: for all such apparatus parameters and all additions before/on unsalted boiling, final capacity is positive, postmix state is at least 19 C and no hotter than the preaddition water, net power increases, and immediate addition minimizes time to salted boiling. Material signs, mixing law, net-power jump, integrated stage-time law and monotonic timing inference are proved intermediates. No sorry or extra axiom is used. Compilation/extraction/kernel checking assess this conditional mathematical statement; empirical accuracy and human acceptance remain separate.

Sources actually incorporated

External response f7c987a52391410bb035542305825b3f, supplied source PDFs/texts and sources.json with hashes:
 NIST GLP10, density at 20 C: https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf
 Partanen & Partanen 2023, DOI 10.1007/s10953-023-01322-y, Eqs.13-19 and Tables 2,8: https://doi.org/10.1007/s10953-023-01322-y
 Partanen & Partanen 2025, DOI 10.1007/s10953-024-01412-5, Eqs.9-10,18 and baseline discussion: https://doi.org/10.1007/s10953-024-01412-5
 NIST-JANAF crystalline NaCl sensible-heat guidance: https://janaf.nist.gov/tables/Cl-055.html
 NIST WebBook molar mass and correlation range: https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2
 IAPWS R6-95(2018), pure-water thermal and phase relationships: https://iapws.org/technical-guidance/release/IAPWS-95

The bundle's Archer PDF/OCR is not used for numerical calibration. No unverified OCR coefficients are used. Arithmetic and sampled residuals are reproducible in evidence/cycle5/evaluate_material_model.py and material-model-evaluation.json. These are calculations about the chosen empirical model, not external responses or independent measurements.
{
  "decision": "reject",
  "binding": "62cab12cdba708c93364b16f366c5ec3e07f7bfe8373db3a4203382271742318",
  "reason": "Human review of attempt 004: revise the material-model derivation and surface all approximation gaps.\n\nHuman instructions, verbatim:\n\"List that 0.99820675 should be derived. it's a minor thing, we'll accept it if there will be no more errors. What's next?\"\n\"Interpolation should be derived, not assumed. Does he make any more analogous errors?\"\nAfter the operator listed the issues below: \"Ok, surface it all to him and send him on the next attempt. claude fish finished?\"\n\nThe following consolidates the entire review of this candidate. These are gaps in the material-property-to-timing derivation, not a report that the checked algebra is inconsistent. Empirical data and a justified empirical correlation may be premises; their derived parameters, numerical consequences and the timing implication must be established in Lean. The human still does not require a numerical heating duration or time saving.\n\n1. Solvent mass (minor): derive 0.99820675 kg from the supplied litre and the cited reference density, with explicit unit conversions, rather than inserting it independently into the molality formula. The human had said this omission alone would not prevent acceptance if there were no further errors; there are additional issues below. Do not represent this as full acceptance of the candidate.\n\n2. Concentration-dependent v and q: the linear interpolation between m=0.15 and m=0.20 is an extra physical approximation. Implementing its arithmetic does not prove that it agrees with the source material-property model at m about 0.1714. Prefer formalizing/evaluating the original concentration-dependent relations provided by the paper (including the relevant equations 15-18 and justified coefficients), deriving v and q for the scenario concentration. If using interpolation instead, derive a bound against the chosen source model sufficient to preserve the conclusion; two tabulated points alone do not establish physical linearity.\n\n3. Standard dissolution enthalpy at 20 C: interpolation between actual 19.97 and 25 C data has no proved approximation-error treatment. This is a minor near-point interpolation, but it must be exposed and justified or derived from a supported temperature-dependent source model, with its uncertainty kept distinct from exact arithmetic.\n\n4. Standard dissolution enthalpy at 100 C: the extrapolation beyond the last 95.18 C data point using the 84.98-to-95.18 segment is more substantial. The source does not certify linear continuation or its error. Use an applicable temperature-dependent model or justify and bound this extrapolation sufficiently for the qualitative claim. The source bundle contains additional primary thermodynamic material; verify equations/coefficients against original pages rather than trusting OCR.\n\n5. Solid NaCl sensible heat: the effective constant 51 J/(mol K) is a chosen approximation guided by nearby data. Derive the 20-to-100 C solid sensible-enthalpy increment from an applicable source heat-capacity relation, or prove adequate integral bounds from supported property assumptions. Do not quietly extrapolate a fit below its stated lower temperature.\n\n6. Effective constant capacity / secant reduction (main concern): naclCapacityChange fits two endpoint enthalpies and then the final proof treats that slope as the actual constant solution-minus-water capacity throughout 19..101 C. Agreement at endpoints and a few Python residual checks do not establish intermediate behavior or preservation of the optimal addition timing. Derive the relevant thermodynamic behavior from the temperature-dependent material model and prove the needed sign/timing conditions over the applicable interval, or establish an approximation/error theorem sufficient to transfer the recommendation. Do not merely rename a fitted slope as the physical capacity increment. Do not discard temperature dependence solely to obtain a tractable conclusion.\n\n7. Other numeric premises: C>=3900 J/K and the pure-water/brine boiling-temperature intervals remain assumptions. Where feasible derive them from component storage, supported pure-water properties, specified pressure and an applicable phase-equilibrium/composition model, rather than inserting aggregate numerical bounds. Otherwise clearly expose precisely what remains an independently justified physical input for human review. These are separate from the already accepted shared Newtonian-loss approximation.\n\nRetain the original litre/20 C problem, your independently chosen 10 g NaCl scenario, primary evidence response f7c987a52391410bb035542305825b3f, and prior attempts. Keep the common constant-input Newtonian heating/loss model already accepted by the human. Source values must retain temperature, composition, units and reference-state meaning. No other agent's proof, material parameters or answer is supplied. Do not choose a new physical quantity or force signs to preserve the current optimum. Prove the qualitative timing conclusion actually implied by the justified model, and request genuinely missing evidence if necessary. No revised proof is accepted until human review.\n",
  "time": "2026-11-17T23:57:47.752932+00:00",
  "verification_verdict": "proved"
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-16T18:27:31.048579+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean",
    "conclusions": [
      "addition_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "addition_timing_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "HeatingRun",
      "HeatBalance"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "addition_timing_answer": {
        "original_sha256": "52894b2acf5bc09ce197451177b4618f9dbe95c87b766f295812a03077606c18",
        "extracted_sha256": "52894b2acf5bc09ce197451177b4618f9dbe95c87b766f295812a03077606c18"
      }
    },
    "dependency_faithful": {
      "HeatingRun": true,
      "HeatingRun.mk": true,
      "HeatBalance": true,
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "HeatingRun.x": true,
      "HeatingRun.a": true,
      "HeatingRun.t": true,
      "HeatingRun.z": true
    },
    "dependency_identities": {
      "HeatingRun": {
        "original_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e",
        "extracted_sha256": "d6b9feecf9b855658652ea1ce6eb8f51a4fc6eeb7424830132f4390cdcee9a7e"
      },
      "HeatingRun.mk": {
        "original_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429",
        "extracted_sha256": "c047d2a78895f3b1cfc4cc7e66d431019bafcc3b43ec57b1b568c82c7eba0429"
      },
      "HeatBalance": {
        "original_sha256": "2e5a83c6c8dda7b7be5db30875038773a065f300c0e75be490f5e69df9d81069",
        "extracted_sha256": "2e5a83c6c8dda7b7be5db30875038773a065f300c0e75be490f5e69df9d81069"
      },
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "HeatingRun.x": {
        "original_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4",
        "extracted_sha256": "2604f4f375e1cc362d011c29fd0b73f525985bd98e54c516bc0fe8875514e0e4"
      },
      "HeatingRun.a": {
        "original_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8",
        "extracted_sha256": "d9eafbb84026acef8d28b6de6d33b42e8864abca840b41f6bf037c09ba1a4ce8"
      },
      "HeatingRun.t": {
        "original_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4",
        "extracted_sha256": "02c422051006de61e6c42f6228800743ffe8bb3dc07243c3a40aed18798ff4e4"
      },
      "HeatingRun.z": {
        "original_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423",
        "extracted_sha256": "ec53476ef0b39af757bc4441aaabb60ba81effa5dfd6c2292e1ac9761bc8b423"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "addition_timing_answer": "\u2200 (C S H Ts B P Q : \u211d) (r s : HeatingRun), 0 < C \u2192 0 \u2264 S \u2192 0 < P \u2192 0 < Q \u2192 HeatBalance C S H Ts B P Q r \u2192 HeatBalance C S H Ts B P Q s \u2192 r.x < s.x \u2192 (r.t < s.t \u2194 P < Q) \u2227 (s.t < r.t \u2194 Q < P) \u2227 (s.t = r.t \u2194 Q = P) \u2227 (Q = P \u2192 r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P)"
    },
    "extracted_file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean:68:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean:103:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean:68:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean:103:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
'addition_timing_answer' depends on axioms: [propext, Classical.choice, Quot.sound]
VAS_LISTED

leanchecker exit 0

shell input
{
  "command": "/usr/bin/bash -lc \"rg -n '18\\\\)|19\\\\)|20\\\\)|15\\\\)|16\\\\)|17\\\\)|Table 2|Table 3|Table 4|infinite|273|373' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt | head -75; rg -n '18\\\\)|19\\\\)|20\\\\)|22\\\\)|infinite|273|373' /work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt | head -65; cat /work/inputs/material-evidence-001/sources.json\""
}
shell output · exit 0
/usr/bin/bash: line 1: rg: command not found
/usr/bin/bash: line 1: rg: command not found
{
  "retrieved_at": "2026-11-17T23:29:22.974500+00:00",
  "kind": "Primary-source material-property literature, not physical measurements or a timing recommendation",
  "sources": [
    {
      "file": "partanen-2025-heat-capacity.pdf",
      "source_url": "https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf",
      "bytes": 1504497,
      "sha256": "7e35e7a61dc456c001e0ef2f33786b34b60d645da7a09fa0ab70869de606a6f9",
      "text_bytes": 129401,
      "extraction": "pdftotext -layout; whitespace/equation layout may need original PDF verification"
    },
    {
      "file": "partanen-2023-enthalpy.pdf",
      "source_url": "https://acris.aalto.fi/ws/portalfiles/portal/126147523/CHEM_Partanen_L_and_Partanen_J_Thermodynamically_Traceable_2023_J_Solution_Chem.pdf",
      "bytes": 1592251,
      "sha256": "5634838e68bef08c086d2a291d6a6764e0603942c37fef8551db3d7093070130",
      "text_bytes": 149390,
      "extraction": "pdftotext -layout; whitespace/equation layout may need original PDF verification"
    },
    {
      "file": "archer-1992-nacl-water.pdf",
      "source_url": "https://www.nist.gov/system/files/documents/srd/jpcrd440.pdf",
      "bytes": 3083239,
      "sha256": "54591c01d4a1f2dd39ece89fe777b3e25ef91e245592d793886d8712eac5f1d2",
      "text_bytes": 37,
      "extraction": "Scanned PDF: text extraction empty; inspect original pages/OCR"
    },
    {
      "file": "nist-water-density.pdf",
      "source_url": "https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf",
      "bytes": 1801418,
      "sha256": "95a4699e41a3fcc4f327a4e5a28e1b91c05b4dbfd64c1c3ac2e2104d5095306d",
      "text_bytes": 343576,
      "extraction": "pdftotext -layout; whitespace/equation layout may need original PDF verification"
    },
    {
      "file": "iapws95-2018.pdf",
      "source_url": "https://iapws.org/technical-guidance/release/IAPWS-95.download",
      "bytes": 380240,
      "sha256": "512879217b94f4d0741c88cab743d41098268914d538d73e680a736cb1c3aad7",
      "text_bytes": 78906,
      "extraction": "pdftotext -layout; whitespace/equation layout may need original PDF verification"
    },
    {
      "file": "nist-janaf-nacl-solid.html",
      "source_url": "https://janaf.nist.gov/tables/Cl-055.html",
      "retrieved_url": "https://janaf.nist.gov/tables/Cl-055.html",
      "bytes": 11408,
      "sha256": "828810708e7d79d8387d78ff60b31d7ea5713478ca83be86545716bbc479949c",
      "text_file": "nist-janaf-nacl-solid.txt",
      "text_bytes": 2604
    },
    {
      "file": "nist-webbook-nacl.html",
      "source_url": "https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2",
      "retrieved_url": "https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2",
      "bytes": 27992,
      "sha256": "e83320ebbf3b6414fd8c4690352144ba0039c0b1f3ae019d2e009e73bef6dcaf",
      "text_file": "nist-webbook-nacl.txt",
      "text_bytes": 6724
    }
  ],
  "retrieval_note": "Legacy mail.iapws.org endpoint failed TLS hostname verification; used current official IAPWS download instead, without disabling TLS verification.",
  "derived_files": [
    {
      "file": "archer-1992-nacl-water-ocr.txt",
      "bytes": 147294,
      "sha256": "7a6763c4f9c0d9446ab38e130f0148dbaccc1266aa0da9d72157a594d354a879",
      "kind": "OCR transcription, not authoritative"
    },
    {
      "file": "water-density-evaluation.json",
      "bytes": 724,
      "sha256": "9a11bb276e7a333db316c0f060b28a52009294d53c565e4f5372a6731b8d455c",
      "kind": "Operator arithmetic evaluation, not measured data"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport pathlib,json\nfor p in pathlib.Path('/work/checks').glob('*/verdict.json'):\n d=json.loads(p.read_text());print(p.parent.name,d.get('time'),d.get('verdict'),d.get('error',''))\np=pathlib.Path('/work/inputs/material-evidence-001/partanen-2023-enthalpy.txt')\nlines=p.read_text().splitlines()\nfor i,l in enumerate(lines):\n if any(s in l for s in ['(15)','(16)','(17)','(18)','(19)','Table 2','Table 3','Table 4']):\n  print('\\\\nLINE',i+1); print('\\\\n'.join(lines[max(0,i-8):i+16]))\nPY\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-023-01322-y

https://doi.org/10.1007/s10953-024-01412-5

cd3bf32329e547d19d474c1bd79431b9 2026-11-16T18:27:31.048579+00:00 proved 
3366e6e934024e17b8832b7253fbd31c 2026-11-17T23:41:59.788687+00:00 not_proved independent extraction failed
8ce875bbeedf40f384474d008e4dfa66 2026-11-17T15:48:51.378080+00:00 proved 
19e916da3a2f417381acb479d8151af9 2026-11-17T14:22:00.296935+00:00 proved 
0a52ddc3554b4e10b6c5b477fceb0093 2026-11-17T23:45:21.072186+00:00 proved 
eb1f4719481a42c1a8b798b0b91aca4d 2026-11-16T18:25:46.169042+00:00 not_proved Lean, kernel recheck or axiom audit failed; see lean.log
45e3bdc1f6974c4dae446c78777c9f79 2026-11-17T23:44:19.408976+00:00 not_proved Lean, kernel recheck or axiom audit failed; see lean.log
f49ea96bd5de45babf8f3c699ba15e09 2026-11-16T18:26:03.961421+00:00 not_proved independent extraction failed
fa26349a1ab0402c9d16ff1354b2240b 2026-11-17T23:42:43.075074+00:00 not_proved independent extraction failed
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '1,160p' /work/inputs/material-evidence-001/nist-janaf-nacl-solid.txt; sed -n '200,450p' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt\""
}
shell output · exit 0
https://doi.org/10.1063/1.555915

https://janaf.nist.gov/tables/Cl-055.html
assistant
The last candidate passed the formal check, but the human rejected its material model. The main gap is the constant-capacity reduction: fitting two endpoint enthalpies does not establish the behavior between them. I’m checking what the temperature-dependent model needs to establish before revising the timing proof.
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '360,420p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt; sed -n '450,486p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt; sed -n '1270,1410p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt; grep -nE 'standard.state|standard-state|heat capacity|Table 8|TABLE 8|Eq. \\\\(2[0-9]' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt | head -50\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-023-01322-y

https://doi.org/10.1063/1.555915
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/45e3bdc1f6974c4dae446c78777c9f79/lean.log | tail -25; cat /work/checks/0a52ddc3554b4e10b6c5b477fceb0093/verdict.json | head -22; ls /work/evidence/cycle5; cat /work/lean-env.sh'"
}
shell output · exit 0
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ B) ∧
    0 < netPower W k 20 x ∧
      0 <
        netPower W k 20
          (mixedTemperature C naclCapacityChange naclDissolutionAt20 20
            x) := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20 19 B0 initialTemperature B0 x
  hc0 hc hk
  (Eq.mpr (id (congrArg (fun _a => 19 ≤ _a) hi))
    (Mathlib.Meta.NormNum.isNat_le_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 19))
      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 20)) (Eq.refl true)))
  (le_refl initialTemperature) hdomain (le_refl B0) hz19 hzB hpow0 hpowB
  hx) (hj : netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x =
  k * (naclCapacityChange * (x - 20) + naclDissolutionAt20) /
    (C +
      naclCapacityChange) := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x
  (ne_of_gt
    hc)) (hjpos : 0 <
  netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) -
    netPower W k 20
      x := Eq.mpr (id (congrArg (fun _a => 0 < _a) hj))
  (div_pos (mul_pos hk (hcool x hx))
    hc)) ⊢ netPower W k initialTemperature x <
  netPower W k initialTemperature
    (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x) VAS_END
VAS_LISTED
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T23:45:21.072186+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean",
    "conclusions": [
      "nacl_immediate_addition_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "nacl_immediate_addition_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
check-1.txt
check-2.txt
check-3.txt
check-4.txt
evaluate_material_model.py
extract-trace-1.txt
extract-trace-2.txt
extracted-conclusion-repr.txt
local-lean-1.log
local-lean-2.log
local-lean-3.log
local-lean-4.log
material-model-calculation.log
material-model-evaluation.json
original-conclusion-repr.txt
revision-trace.txt
trace-extracted.json
trace-extracted.lean
trace-extraction-result.txt
trace_extraction.py
export LEAN_PATH=/harness/.lake/packages/plausible/.lake/build/lib/lean:/harness/.lake/packages/proofwidgets/.lake/build/lib/lean:/harness/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/harness/.lake/packages/mathlib/.lake/build/lib/lean:/harness/.lake/packages/aesop/.lake/build/lib/lean:/harness/.lake/packages/batteries/.lake/build/lib/lean:/harness/.lake/packages/importGraph/.lake/build/lib/lean:/harness/.lake/packages/Qq/.lake/build/lib/lean
shell input
{
  "command": "/usr/bin/bash -lc \"grep -n -A28 -B20 '(22)' /work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt | head -130; sed -n '2820,2880p' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt; sed -n '910,1020p' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt; sed -n '2250,2380p' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-024-01412-5

https://doi.org/10.1063/1.555915
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '670,730p' /work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt; sed -n '1050,1180p' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt; sed -n '1,90p' /work/evidence/cycle5/revision-trace.txt\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-023-01322-y

https://doi.org/10.1007/s10953-024-01412-5

Cycle 5 lineage, 2026-11-17 UTC

Reviewed supplied human feedback and cycle-3 accepted mathematical check (8ce875bbeedf40f384474d008e4dfa66), as well as the older preserved extraction failure f49ea96bd5de45babf8f3c699ba15e09. Cycle-3 scientific answer remained rejected. Incorporated operator material response f7c987a52391410bb035542305825b3f and read its original source text/PDF bundle; no previous solution or external agent was consulted.

Kept the previously selected 10 g dry crystalline NaCl case. Calibrated a 20-to-100 C effective enthalpy secant from the supplied dissolution enthalpies and concentration correction. Disclosed concentration interpolation, standard-enthalpy extrapolation, solid Cp approximation, affine approximation and apparatus conditions. Computed sampled residuals; did not reinterpret them as uniform validation. Retained the generic signed-capacity timing theorem and energy derivations, added one direct physical-case conclusion.

Local command local-lean-1.log records a wrong guessed executable location, then local-lean-2.log records actual parsing/layout and rewriting errors. The final let binding needed a semicolon so the unary-minus body could not be parsed as continued subtraction; the mixed-temperature lower-bound proof needed rewriting the initial-temperature definition in the goal as well as its hypothesis. No mathematical assumption changed in these repairs. local-lean-3.log subsequently compiled without errors (warnings are retained).

Protocol check 1: checks/3366e6e934024e17b8832b7253fbd31c; lean_exit=0, standalone extraction compiles, every model dependency faithful, but final conclusion identity false. Raw result is check-1.txt. Replaced only the theorem's scientific decimal 100.1 by the exactly equivalent (1001 / 10 : real) to avoid generated proof identity differences during pretty-print extraction; no model or physical bound changed. Protocol check 2 is recorded separately in check-2.txt. Its actual verdict, not local compilation, determines verification status. No human approval is inferred.

Protocol check 2 also compiled but failed conclusion identity, so replacing only the decimal was insufficient. Instrumented the installed extractor using the run's pre-existing tracing method, preserving both raw repr traces. Differences identify Real numeric literals' auxiliary proof arguments (original theorem inline, extracted definition lifted). Protocol check 3 replaced all >=2 Real literals in the public theorem with exact natural-to-real casts and reused initialTemperature=20. It then reported real proof elaboration errors in lean.log because arithmetic tactics did not normalize those casts/temperature references automatically. Added proof-local normalization of casts and initialTemperature only. local-lean-4.log compiles this revised proof successfully. Protocol check 4 records the actual independent result. No scientific bound, assumption, data point or conclusion changed during these representation repairs.
web_search input
{
  "query": "https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf",
  "action": {
    "type": "open_page",
    "url": "https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "acris.aalto.fi",
      "ref_id": "turn0view0",
      "snippet": "Total lines: 1605",
      "url": "https://acris.aalto.fi/ws/portalfiles/portal/182634190/Thermodynamically_Traceable_Calorimetric_Results_for_Aqueous_Sodium_Chloride_Solutions_from_T_273.15_to_373.15_K_up_to_the_Saturated_Solutions_Part_2.pdf"
    },
    {
      "type": "text_result",
      "domain": "www.nist.gov",
      "ref_id": "turn0view1",
      "snippet": "Total lines: 0",
      "title": "ð‰Q",
      "url": "https://www.nist.gov/system/files/documents/srd/jpcrd440.pdf"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '720,745p' /work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt; sed -n '555,640p' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt; sed -n '1018,1100p' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt\""
}
shell output · exit 0
https://doi.org/10.1007/s10953-024-01412-5

https://doi.org/10.1063/1.555915
web_search input
{
  "query": "",
  "action": {
    "type": "other"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "ref_id": "turn1view0",
      "title": "Internal Error"
    },
    {
      "type": "text_result",
      "ref_id": "turn1view1",
      "title": "Internal Error"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc \"grep -n -A70 'References' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt | tail -75; sed -n '1090,1165p' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt; grep -nE 'Archer|1991|1992|4D\\\\.|4 D|4,' /work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt | tail -30; command -v pdftoppm\""
}
shell output · exit 1 · failed
https://doi.org/10.1063/1.555915
web_search input
{
  "query": "site.nist.gov Archer \"Thermodynamic Properties of the NaCl\" \"I.\" 1992 1 21",
  "action": {
    "type": "search",
    "query": "site.nist.gov Archer \"Thermodynamic Properties of the NaCl\" \"I.\" 1992 1 21"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn2search12",
      "snippet": "Thermodynamic Properties of the NaCl+H₂O System I. ... Cite as: Journal of Physical and Chemical Reference Data 21, 1 (1992); https://doi.org/10.1063/1.555913 ... Archer",
      "title": "ÀÑL",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555913.pdf"
    },
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn2search13",
      "snippet": "Cite as: Journal of Physical and Chemical Reference Data 21, 793 (1992); https://doi.org/10.1063/1.555915 ... Archer ... Thermodynamic Properties of the NaCl+H2O System I.",
      "title": "ð‰Q",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555915.pdf"
    },
    {
      "type": "text_result",
      "domain": "www.nist.gov",
      "ref_id": "turn2search0",
      "snippet": "Compounds of Carbon, Hydrogen, Halogens, Nitrogen, Oxygen, and Sulfur | Vlastimil R&uring;zi&ccaron;ka, Jr., and Eugene S. ... 1992 | Thermodynamic Properties of the NaCl +",
      "title": "NIST Standard Reference Database Journal of Physical and Chemical Reference Data Reprints | NIST",
      "url": "https://www.nist.gov/srd/nist-standard-reference-database-journal-physical-and-chemical-reference-data-reprints"
    },
    {
      "type": "text_result",
      "domain": "nvlpubs.nist.gov",
      "ref_id": "turn2search14",
      "snippet": "(Chemical Kinetics and Thermodynamics Division) ... Archer, D.G., \"Thermodynamic Properties of the NaCl + H2O System. ... Data 21, 1-21 (1992). Archer, D.G., \"Thermodynamic Properties",
      "title": "Chemical Science and Technology Laboratory, technical activities 1992",
      "url": "https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nistir5111.pdf"
    },
    {
      "type": "text_result",
      "domain": "pascal-francis.inist.fr",
      "ref_id": "turn2search1",
      "snippet": "\"O:12:\\\"IstexOpenUrl\\\":35:{s:10:\\\"\\u0000*\\u0000openUrl\\\";N;s:6:\\\"\\u0000*\\u0000fmt\\\";s:7:\\\"journal\\\";s:6:\\\"\\u0000*\\u0000doi\\\";s:16:\\\"10.1063\\/1.555913\\\";s:6:\\\"\\u0000*\\u0000pii\\\";s:0:\\\"\\\";s:7:\\\"\\u0000*\\",
      "title": "Thermodynamic properties of the NaCl + H2O system. I: Thermodynamic properties of NaCl(cr)",
      "url": "https://pascal-francis.inist.fr/vibad/index.php?action=getRecordDetail&idt=5566851"
    },
    {
      "type": "text_result",
      "domain": "acris.aalto.fi",
      "ref_id": "turn2search15",
      "snippet": "Journal of Chemical & Engineering Data ... I. ... (38) Archer, D. ... The specific volume of steam in the saturated and superheated condition together",
      "title": "Journal of Chemical & Engineering Data",
      "url": "https://acris.aalto.fi/ws/portalfiles/portal/53170593/acs.jced.0c00402.pdf"
    },
    {
      "type": "text_result",
      "domain": "www.electronicsandbooks.com",
      "ref_id": "turn2search16",
      "snippet": "Journal of Chemical and Engineering Data, Vol. ... Thermodynamic Properties of the NaCl + H2O System. I. ... 1992a, 21, 1-21. ... Thermodynamic Properties of",
      "title": "281\nJ. Chem. Eng. Data 1997, 42, 281-292\nEnthalpy",
      "url": "https://www.electronicsandbooks.com/edt/manual/Magazine/J/Journal%20of%20Chemical%20%26%20Engineering%20Data/40-43/je960224q.pdf"
    },
    {
      "type": "text_result",
      "domain": "pytzer.hseao3.group",
      "ref_id": "turn2search2",
      "snippet": "A92ii: Archer (1992) J. ... Thermodynamic Properties of the NaCl + H_{2}O System. ... Journal of Physical and Chemical Reference Data 21, 793–829. doi:10.1063/1.555915",
      "title": "References - Pytzer",
      "url": "https://pytzer.hseao3.group/refs/"
    },
    {
      "type": "text_result",
      "domain": "pytzer.readthedocs.io",
      "ref_id": "turn2search3",
      "snippet": "A92ii: Archer (1992) J. ... Thermodynamic Properties of the NaCl + H_{2}O System. ... Journal of Physical and Chemical Reference Data 21, 793–829. doi:10.1063/1.555915 ...",
      "title": "References - Pytzer",
      "url": "https://pytzer.readthedocs.io/en/latest/refs/"
    },
    {
      "type": "text_result",
      "domain": "papers.ssrn.com",
      "ref_id": "turn2search4",
      "snippet": "### Jaakko I. ... D G Archer Thermodynamic properties of the NaCl+H 2 O system. ... Data , volume 21 , p. 793 - 829",
      "title": "Thermodynamically Traceable Calorimetric Results for Aqueous Sodium Chloride Solutions at Temperatures from T = (273.15 to 373.15) K Up to the Saturated Solutions. Part 1. The Quantities Associated with the Partial Molar Enthalpy",
      "url": "https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4057445"
    },
    {
      "type": "text_result",
      "domain": "www.scribd.com",
      "ref_id": "turn2search5",
      "snippet": "Archer Fecpobve Data Cen, National Ins of Sandarts and Technolgy, Gathonburg MD 20899 [Reosited May 2, 1991; revised manuscript received October 1, 1991 ‘The available",
      "title": "Archer (1991) | PDF",
      "url": "https://www.scribd.com/document/790276095/Archer-1991"
    },
    {
      "type": "text_result",
      "domain": "www.ap1700.com",
      "ref_id": "turn2search6",
      "snippet": "Image: 物性参数计算模型参考文献 Thermodynamic Properties of Oxygen from the Triple Point to 300 K with Pressures to 80 MPa ... 917-1021 (1991) ... Archer ... Thermodynamic",
      "title": "参考文献 - AP1700物性参数在线计算与查询平台",
      "url": "https://www.ap1700.com/Reference.htm"
    },
    {
      "type": "text_result",
      "domain": "www.researchgate.net",
      "ref_id": "turn2search7",
      "snippet": "i ... K−1·mol−1 for solid NaCl in the temperature range of 273−373 ... This was based on the data by Archer. ... Thermodynamic properties of",
      "title": "Traceable Values for Activity and Osmotic Coefficients in Aqueous Sodium Chloride Solutions at Temperatures from 273.15 to 373.15 K up to the Saturated Solutions",
      "url": "https://www.researchgate.net/publication/346581020_Traceable_Values_for_Activity_and_Osmotic_Coefficients_in_Aqueous_Sodium_Chloride_Solutions_at_Temperatures_from_27315_to_37315_K_up_to_the_Saturated_Solutions"
    },
    {
      "type": "text_result",
      "domain": "www.researchgate.net",
      "ref_id": "turn2search8",
      "snippet": "Archer, D.G., Thermodynamic properties of the NaCl ... 1992, 21(1), 1-21, http://dx. doi.org/10.1063/1.555913 ... Archer, D.G., Thermodynamic properties of the NaCl ... Physical and Chemical",
      "title": "Mathematical modelling of density and viscosity of NaCl aqueous solutions",
      "url": "https://www.researchgate.net/publication/280063894_Mathematical_modelling_of_density_and_viscosity_of_NaCl_aqueous_solutions"
    },
    {
      "type": "text_result",
      "domain": "www.scribd.com",
      "ref_id": "turn2search9",
      "snippet": "Thermodynamic Properties of the NaCl + H2O ... Physical and Chemical Properties Division, Chemical Science and Technology Laboratory, ... literature to generate models that represented",
      "title": "Enthalpy Measurements of NaCl and KBr | PDF | Heat | Temperature",
      "url": "https://www.scribd.com/document/790276091/Archer-1997"
    },
    {
      "type": "text_result",
      "domain": "www.researchgate.net",
      "ref_id": "turn2search10",
      "snippet": "Thermodynamic Properties of the NaCl+H2O System. ... Archer ... New equations and/or values for the following properties are given in the present work: 1) ΔfG⁰m",
      "title": "Modelling of the thermodynamic and solvation properties of electrolyte solutions with the statistical associating fluid theory for potentials of variable range",
      "url": "https://www.researchgate.net/publication/265389803_Modelling_of_the_thermodynamic_and_solvation_properties_of_electrolyte_solutions_with_the_statistical_associating_fluid_theory_for_potentials_of_variable_range"
    },
    {
      "type": "text_result",
      "domain": "www.researchgate.net",
      "ref_id": "turn2search11",
      "snippet": "Thermodynamic Properties of the NaCl+H2O System. ... Archer ... New equations and/or values for the following properties are given in the present work: 1) ΔfG⁰m",
      "title": "Applications of Thermodynamics to Solutions Containing Electrolyte Solutes",
      "url": "https://www.researchgate.net/publication/301189467_Applications_of_Thermodynamics_to_Solutions_Containing_Electrolyte_Solutes"
    }
  ]
}
assistant
The source paper explicitly discusses disagreement between the absolute heat-capacity baselines. That matters because timing depends on the full, reference-consistent enthalpy curve. I’ll request a verified, internally consistent material model and its uncertainty limits; the next timing proof can then retain temperature-dependent heat capacities.
shell input
{
  "command": "/usr/bin/bash -lc 'mkdir -p /work/history/cycle6-start /work/evidence/cycle6\ncp /work/Model.lean /work/candidate.json /work/report.txt /work/human-feedback.json /work/history/cycle6-start/'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\np=Path('/work/evidence/cycle6')\np.joinpath('revision-notes.txt').write_text('''Cycle 6: review and evidence request; no revised candidate submitted yet.\n\nRead the task-local history, cycle5 report/proof/calibration, current human-feedback.json, material response f7c987a52391410bb035542305825b3f and primary-source excerpts. Preserved rejected files in history/cycle6-start/. The last actual check is checks/0a52ddc3554b4e10b6c5b477fceb0093: proved, complete independent extraction and kernel recheck. Earlier cycle5 checks failed extraction identity and one proof elaboration; those were fixed by explicit casts and proof-local normalization. These diagnostics do NOT address the material-model defects identified by the subsequent human rejection. No human approval is inferred.\n\nThe principal scientific defect is treating the 20-to-100 C enthalpy secant as the actual capacity increment throughout the interval. Neither endpoint matching nor sampled residuals validate that replacement. Also withdraw use of unbounded composition interpolation, standard dissolution-enthalpy interpolation/extrapolation and a constant solid heat capacity as a sufficient physical derivation. The original generic constant-capacity proofs remain conditional mathematics, not a temperature-dependent NaCl result.\n\nProposed temperature-dependent formulation (derived here on paper, NOT yet a Lean theorem): let U(T) be water+pot enthalpy and V(T) final brine+pot enthalpy on the same reference, and K the enthalpy of the 10 g solid held at 20 C. Define D(T)=V(T)-U(T)-K. Adiabatic instantaneous addition at water temperature x gives V(z(x))=U(x)+K. Positive final capacity V'(T)>0 gives sign(x-z(x))=sign(D(x)) wherever both states are in the liquid domain. The shared law N(T)=W-k(T-20) then implies N(z)-N(x)=k(x-z), without presuming its sign.\n\nFor elapsed time tau(x)=integral from 20 to x of U'(T)/N(T) dT + integral from z(x) to B of V'(T)/N(T) dT, implicit differentiation gives V'(z)*z'=U'(x). Hence tau'=U'(x)*(1/N(x)-1/N(z)). Local brine capacity cancels from the timing derivative, but its positivity remains essential for the mixing map and feasibility. Thus uniform D>0 would imply earliest addition under the accepted loss law; D<0 or sign changes require different analysis. No sign or optimum is adopted in advance. This generalization preserves true temperature dependence rather than fitting a constant S. The common salted heating segment above every possible z cancels from comparisons; its heat capacity need not be extrapolated from a 100 C fit merely to determine the comparison, although final-stage existence/phase validity still needs justification.\n\nReference conversion: per mole, D_mol(T)=h_diss(T,m)+[h_cr(T)-h_cr(20)], where h_diss is the integral isothermal dissolution enthalpy at that same T and final molality. D_mol'(T)=C_app(T,m), the absolute apparent solution-minus-water heat capacity, not dissolution Cp difference and not relative apparent capacity. D(total)=n*D_mol. The unchanged pot cancels from D, but contributes to U' and V'. The density-based mass must be derived as (1 L)*(1000 cm\"'^3/L)*(.99820675 g/cm''^3)*(1 kg/1000 g); m=(10 g)/(58.443 g/mol)/mass. The concentration is not a new independent input.\n\nPrimary-source issue found on rereading: Partanen2025 Eq22 uses C_infinite(t)=-8-2t J/(mol K), derived from a solubility-based enthalpy model. Section3.2 (printed296-297) explicitly notes disagreements among absolute baselines and calls its own -58 at25 C less realistic than -84 from Abraham/Marcus. Criss-Cobble-based baseline is a separate alternative. We cannot splice Eq22 into a Criss-Cobble enthalpy curve and retain thermodynamic consistency. These source disagreements make it inappropriate to demand a positive D bound without checking which consistent model supports it.\n\nArcher1992 PartII section2 (printed796, PDFpage4) uses integrals of the NaCl(cr) spline in Ref4, Archer1992 PartI, JPCRD21,1, DOI10.1063/1.555913. That spline is not in the supplied PartII bundle. PartII equations20-22,32-38 describe internally consistent aqueous properties, with coefficients in Table2; OCR is inadequate for formal parameter entry without image verification. PartI was located through the official NIST reprint index: https://srd.nist.gov/jpcrdreprint/1.555913.pdf . No coefficients from its unseen pages have been used. Native source consultation only; no earlier solution, other agent, paid service or authentication material consulted.\n\nNext step: request a verified consistent empirical material representation (or source evaluation with reproducible equations and justified interval/error treatment). Then formalize its derived bounds and the variable-capacity timing theorem. No new check is claimed for these handwritten derivations, and the rejected candidate remains historical pending evidence.\n'\"''')\np.joinpath('request-question.txt').write_text('''Cycle 6 follow-up to literature response f7c987a52391410bb035542305825b3f, after human rejection of the effective constant-capacity approximation. Please supply a verified, internally consistent primary-source thermodynamic representation for the retained 10 g pure dry crystalline NaCl at 20 C / original 1 L water at 20 C case. This is a request for material evidence/model calculations, not physical measurements, a timing recommendation or a Lean proof.\n\nThe essential missing evidence is a temperature-dependent ABSOLUTE enthalpy/capacity representation with one consistent reference. We will derive the timing comparison ourselves with variable capacities. The key material quantity per mole is D_mol(t,m) = h_diss(t,m) + h_cr(t)-h_cr(20 C), where h_diss(t,m) is integral isothermal solid dissolution enthalpy at final composition m and at temperature t, in J/mol. Its derivative in t is the absolute apparent molar heat capacity C_app=[C_solution-C_original_water]/n. The solid sensible term is essential because the stored salt remains at 20 C, while h_diss is referenced to same-temperature reactants. We need its actual curve/sign, not a sign selected to preserve immediate addition.\n\nPlease provide source equations and verified coefficients, with temperature/composition/pressure validity and reference conventions, sufficient to reconstruct D_mol and C_app. A suitable route is unified Archer1992 PartII plus the crystalline-salt spline it references: PartII section2 explicitly refers to Ref4 for that spline, Archer1992 PartI, JPCRD21,1, DOI10.1063/1.555913, located at https://srd.nist.gov/jpcrdreprint/1.555913.pdf . PartI is not in the original bundle. If using this route, please verify the necessary PartII equations/coefficient table against PDF images and supply the needed PartI spline/enthalpy relation, anchor and numerical conventions. The current OCR is not authoritative. Another supported consistent primary-source representation is welcome. If using Partanen, evaluate the full concentration dependence rather than treating adjacent table points as physically linear.\n\nWhy this follow-up is substantive: Partanen2025 Eq22 uses C_infinite(t)=-8-2t, based on a solubility-derived infinite-dilution enthalpy model, whereas the rejected candidate used the separate Criss-Cobble dissolution data. Section3.2 explicitly discusses discrepancies between absolute baselines. Do not silently combine them, use relative C_app as absolute, interpolate/extrapolate sparse enthalpy points without bounds, or certify a secant capacity as a uniform local capacity.\n\nFor calculation/validity, take pressure 0.100 MPa as an explicit near-atmospheric scenario choice aligned with Archer's reference isobar (not a user measurement), ambient and stored solid at20 C. Solvent mass and molality must follow from 1 L, the supplied NIST density and 58.443 g/mol; m is about .171414 mol/kg. We will prove those conversions in Lean. Please evaluate the consistent model near19,20,60,100 C and give its equations sufficient to derive interval bounds over19..100 C, not just samples. Useful outputs are possible extrema/sign changes of D_mol, conservative absolute C_app and pure-water specific Cp bounds, and error/uncertainty information. Any computational bound should distinguish a genuinely certified enclosure from a numerical grid check; source validity/empirical uncertainty is separate from arithmetic certification. If a justified uniform bound is unavailable, say so and give the actual correlation with its limitations instead of inventing one. We can formalize consequences conditional on a clearly justified empirical correlation; do not add a desired timing/sign condition as an unexplained premise.\n\nPlease also provide a coarse phase/solubility check at this composition and pressure: evidence for the liquid range containing the possible mixed states and the pure-water/brine boiling endpoints, preferably establishing or refuting that both boiling endpoints fall below100 C at0.100 MPa. If brine needs a higher-temperature domain, give that domain explicitly. The comparison never allows waiting through pure-water boiling. We need positivity of total water+pot and brine+pot capacities, with pot capacity nonnegative; component bounds are preferable to assuming an aggregate C>=3900. No heater power, loss coefficient, pot mass or physical duration is requested: these remain exposed apparatus conditions under the already accepted common constant-input Newtonian heat-loss model.\n\nPlease preserve citations, original pages and source/provenance details, uncertainty and failures. No other agent's proof/model or preset timing answer is requested. If competing credible internally consistent representations imply different D signs, please flag that rather than selecting a favorable one. We will report a conditional timing answer if the material evidence does not robustly identify a regime.''')\nprint('Saved cycle6 revision notes and pending evidence question.')\nPY\""
}
shell output · exit 0
Saved cycle6 revision notes and pending evidence question.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\nimport subprocess\nquestion=Path('/work/evidence/cycle6/request-question.txt').read_text()\nr=subprocess.run(['python','/harness/src/vcs_protocol.py','tool','request','--kind','literature','--question',question],capture_output=True,text=True)\nPath('/work/evidence/cycle6/request-output.txt').write_text(r.stdout+'\\\\n'+r.stderr)\nprint(r.stdout)\nif r.stderr: print(r.stderr)\nprint('Request command exit:',r.returncode)\nPY\""
}
shell output · exit 0
{"id": "8ee08d44180740abb377ff631b6f1452", "kind": "literature", "question": "Cycle 6 follow-up to literature response f7c987a52391410bb035542305825b3f, after human rejection of the effective constant-capacity approximation. Please supply a verified, internally consistent primary-source thermodynamic representation for the retained 10 g pure dry crystalline NaCl at 20 C / original 1 L water at 20 C case. This is a request for material evidence/model calculations, not physical measurements, a timing recommendation or a Lean proof.\n\nThe essential missing evidence is a temperature-dependent ABSOLUTE enthalpy/capacity representation with one consistent reference. We will derive the timing comparison ourselves with variable capacities. The key material quantity per mole is D_mol(t,m) = h_diss(t,m) + h_cr(t)-h_cr(20 C), where h_diss(t,m) is integral isothermal solid dissolution enthalpy at final composition m and at temperature t, in J/mol. Its derivative in t is the absolute apparent molar heat capacity C_app=[C_solution-C_original_water]/n. The solid sensible term is essential because the stored salt remains at 20 C, while h_diss is referenced to same-temperature reactants. We need its actual curve/sign, not a sign selected to preserve immediate addition.\n\nPlease provide source equations and verified coefficients, with temperature/composition/pressure validity and reference conventions, sufficient to reconstruct D_mol and C_app. A suitable route is unified Archer1992 PartII plus the crystalline-salt spline it references: PartII section2 explicitly refers to Ref4 for that spline, Archer1992 PartI, JPCRD21,1, DOI10.1063/1.555913, located at https://srd.nist.gov/jpcrdreprint/1.555913.pdf . PartI is not in the original bundle. If using this route, please verify the necessary PartII equations/coefficient table against PDF images and supply the needed PartI spline/enthalpy relation, anchor and numerical conventions. The current OCR is not authoritative. Another supported consistent primary-source representation is welcome. If using Partanen, evaluate the full concentration dependence rather than treating adjacent table points as physically linear.\n\nWhy this follow-up is substantive: Partanen2025 Eq22 uses C_infinite(t)=-8-2t, based on a solubility-derived infinite-dilution enthalpy model, whereas the rejected candidate used the separate Criss-Cobble dissolution data. Section3.2 explicitly discusses discrepancies between absolute baselines. Do not silently combine them, use relative C_app as absolute, interpolate/extrapolate sparse enthalpy points without bounds, or certify a secant capacity as a uniform local capacity.\n\nFor calculation/validity, take pressure 0.100 MPa as an explicit near-atmospheric scenario choice aligned with Archer's reference isobar (not a user measurement), ambient and stored solid at20 C. Solvent mass and molality must follow from 1 L, the supplied NIST density and 58.443 g/mol; m is about .171414 mol/kg. We will prove those conversions in Lean. Please evaluate the consistent model near19,20,60,100 C and give its equations sufficient to derive interval bounds over19..100 C, not just samples. Useful outputs are possible extrema/sign changes of D_mol, conservative absolute C_app and pure-water specific Cp bounds, and error/uncertainty information. Any computational bound should distinguish a genuinely certified enclosure from a numerical grid check; source validity/empirical uncertainty is separate from arithmetic certification. If a justified uniform bound is unavailable, say so and give the actual correlation with its limitations instead of inventing one. We can formalize consequences conditional on a clearly justified empirical correlation; do not add a desired timing/sign condition as an unexplained premise.\n\nPlease also provide a coarse phase/solubility check at this composition and pressure: evidence for the liquid range containing the possible mixed states and the pure-water/brine boiling endpoints, preferably establishing or refuting that both boiling endpoints fall below100 C at0.100 MPa. If brine needs a higher-temperature domain, give that domain explicitly. The comparison never allows waiting through pure-water boiling. We need positivity of total water+pot and brine+pot capacities, with pot capacity nonnegative; component bounds are preferable to assuming an aggregate C>=3900. No heater power, loss coefficient, pot mass or physical duration is requested: these remain exposed apparatus conditions under the already accepted common constant-input Newtonian heat-loss model.\n\nPlease preserve citations, original pages and source/provenance details, uncertainty and failures. No other agent's proof/model or preset timing answer is requested. If competing credible internally consistent representations imply different D signs, please flag that rather than selecting a favorable one. We will report a conditional timing answer if the material evidence does not robustly identify a regime.", "time": "2026-11-18T00:01:51.496123+00:00"}
Stop this cycle. A human must supply the actual response before you resume.

Request command exit: 0
assistant
Submitted literature request `8ee08d44180740abb377ff631b6f1452` for consistent temperature-dependent enthalpy, heat-capacity, and phase evidence.

Preserved the rejected candidate and recorded the proposed variable-capacity derivation in [revision notes](/work/evidence/cycle6/revision-notes.txt). No revised timing recommendation or new proof check is claimed. Stopping for the operator’s response.

Produced code

checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢
  dsimp only [initialTemperature] at hW ⊢
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/19e916da3a2f417381acb479d8151af9/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
checks/3366e6e934024e17b8832b7253fbd31c/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ 100.1 →
    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧
    (0 < netPower W k 20 x ∧
      netPower W k 20 x <
        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/45e3bdc1f6974c4dae446c78777c9f79/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ (1001 / 10 : ℝ) →
    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧
    (0 < netPower W k 20 x ∧
      netPower W k 20 x <
        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)

Round 7

Messages

user
The requested missing Archer Part I is now provided, together with a searchable Part II reprint and Parker's original tables. The complete bundle is available at /work/inputs/material-literature-002. Read READING-NOTES.txt, sources.json, the full PDFs and their text, and the original-page PNGs. All supplied files are literature or source transcriptions; no physical measurement, other agent's result, salt-addition recommendation or Lean solution is included.

Part I supplies the natural cubic spline for transformed crystal heat capacity and the knot data; Part II explicitly ties that representation to its aqueous fit. Original equation/coefficient pages have been rendered so OCR signs and units can be checked. Its Eq38 uses kJ, and its Gibbs-energy anchor must not be substituted for an enthalpy. The original Debye-Huckel evaluation uses the cited water/dielectric representations; retain one declared reference. Parker provides an independent tabular reference and an explicit calorie convention. Do not silently splice its absolute baseline into a different correlation.

No operator-certified evaluation of the full aqueous EOS or temperature-uniform material/phase bound is supplied. Use your calculation tools to evaluate the original representation and derive the conversions and inequalities needed in Lean, keeping empirical validity and numerical certification distinct. The source includes the equations and coefficients; no interpolated point has been promoted to a certified curve. If an indispensable coefficient from another cited primary reference is missing, identify that exact dependency. Do not select a favorable sign, use a secant as a uniform capacity, or add the requested timing conclusion as a premise. Your requested fixed-temperature solid reference and apparatus choices remain your declared modeling choices, subject to the human review already in progress.
assistant
I’ll review the latest feedback, proof history, and new primary-source bundle, then work through the temperature-dependent material model and its implications for salt-addition timing.
shell input
{
  "command": "/usr/bin/bash -lc \"pwd; rg --files -g '\"'!*.pdf'\"' -g '\"'!*.png'\"' -g '\"'!*.jsonl'\"' -g '\"'!*.log'\"' . | head -100\""
}
shell output · exit 0
/work
/usr/bin/bash: line 1: rg: command not found
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work; find /work -maxdepth 3 -type f | head -100'"
}
shell output · exit 0
total 108
drwxrwxr-x  8 1001 1001  4096 Nov 17 23:57 .
drwxr-xr-x  1 root root  4096 Nov 18 00:51 ..
-rw-r--r--  1 1001 1001 21006 Nov 17 23:45 Model.lean
-rw-r--r--  1 1001 1001  4229 Nov 17 23:41 candidate.json
drwxr-xr-x 11 1001 1001  4096 Nov 17 23:45 checks
drwxr-xr-x  2 1001 1001  4096 Nov 17 15:48 diagnostics
drwxr-xr-x  5 1001 1001  4096 Nov 18 00:01 evidence
drwxr-xr-x  7 1001 1001  4096 Nov 18 00:01 history
-rw-------  1 1001 1001  5340 Nov 17 23:57 human-feedback.json
drwxrwxr-x  4 1001 1001  4096 Nov 18 00:50 inputs
-rw-------  1 1001 1001 15186 Nov 17 23:47 last-review-packet.json
-rw-r--r--  1 1001 1001   456 Nov 17 14:15 lean-env.sh
-rw-r--r--  1 1001 1001 14551 Nov 17 23:41 report.txt
drwxr-xr-x  2 1001 1001  4096 Nov 18 00:50 requests
/work/report.txt
/work/human-feedback.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-report.txt
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-candidate.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/lean.log
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted-report.txt
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted-candidate.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/lean.log
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/extracted.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/extracted.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/verdict.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/Checked.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-report.txt
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-candidate.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/lean.log
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-report.txt
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-candidate.json
/work/checks/19e916da3a2f417381acb479d8151af9/lean.log
/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.json
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/verdict.json
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted-report.txt
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted-candidate.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/lean.log
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/verdict.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/Checked.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-report.txt
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-candidate.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted-report.txt
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted-candidate.json
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/lean.log
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted.lean
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/verdict.json
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/Checked.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-report.txt
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-candidate.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/lean.log
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted-report.txt
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted-candidate.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/lean.log
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/extracted.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/extracted.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/verdict.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/Checked.lean
/work/diagnostics/extraction-result.txt
/work/diagnostics/cycle3-compile-1.log
/work/diagnostics/probe2.log
/work/diagnostics/extract-trace-1.txt
/work/diagnostics/cycle3-check-1.txt
/work/diagnostics/cycle2-compile-4.log
/work/diagnostics/cycle2-compile-1.log
/work/diagnostics/cycle2-compile-3.log
/work/diagnostics/probe.log
/work/diagnostics/extraction_trace.py
/work/diagnostics/extract-trace-2.txt
/work/diagnostics/extracted.json
/work/diagnostics/cycle2-check-1.txt
/work/diagnostics/cycle3-compile-3.log
/work/diagnostics/extracted.lean
/work/diagnostics/cycle2-compile-2.log
/work/diagnostics/probe2.lean
/work/diagnostics/probe.lean
/work/diagnostics/cycle3-compile-2.log
/work/Model.lean
/work/lean-env.sh
/work/history/cycle6-start/report.txt
/work/history/cycle6-start/human-feedback.json
/work/history/cycle6-start/Model.lean
/work/history/cycle6-start/candidate.json
/work/history/cycle5-start/report.txt
/work/history/cycle5-start/Model.lean
/work/history/cycle5-start/candidate.json
/work/history/cycle1/report.txt
/work/history/cycle1/human-feedback.json
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/inputs/material-literature-002/READING-NOTES.txt; cat /work/inputs/material-literature-002/sources.json; ls -R /work/evidence; cat /work/checks/fa26349a1ab0402c9d16ff1354b2240b/verdict.json; head -65 /work/Model.lean'"
}
shell output · exit 0
Primary thermodynamic literature supplied by the operator, 18 November 2026

This is literature and source transcription, not a physical experiment or a timing recommendation. It contains no other scientist's model, proof or answer. PDF page numbers below are one-based and include front matter.

Parker, Thermal Properties of Aqueous Uni-univalent Electrolytes, NSRDS-NBS 2 (1965), DOI 10.6028/NBS.NSRDS.2.
https://nvlpubs.nist.gov/nistpubs/Legacy/NSRDS/nbsnsrds2.pdf
Printed p26 / PDF p34: NaCl(cr) infinite-dilution dissolution enthalpy at 25 C is +928 +/-5 cal/mol. Table X, printed p50 / PDF p58, gives the relative apparent molar enthalpy Phi_L at 25 C. Table II C, printed p43 / PDF p51, gives the apparent molar heat capacity Phi_C at 15,20,25,30 C. Table XIX, printed p64 / PDF p72, lists contributing infinite-dilution results. Source units are thermochemical calories: 1 cal=4.1840 J. Phi_L is relative to infinite dilution, not the complete dissolution enthalpy; Phi_C is apparent heat capacity, not the solid's heat capacity. Sparse table entries do not establish interpolation, a derivative between rows, or a temperature-uniform enclosure. See the CSVs and original page images. The quoted +/-5 is Parker's uncertainty statement, not a certified uniform error for an interpolating model.

Archer, Thermodynamic Properties of the NaCl+H2O System, Part I: NaCl(cr), JPCRD21,1-21 (1992), DOI 10.1063/1.555913.
https://srd.nist.gov/jpcrdreprint/1.555913.pdf
Printed p4 / PDF p5, Eqs4-6: fit f(T) with a natural cubic spline; b=.25, T0=1 K, Cp0=1 J/(mol K); Cp_cr/Cp0=[T/(T0*f(T)+b*T)]^3. Table3, printed p11 / PDF p12, supplies all knot abscissas and values (see archer-solid-knots.csv); both end conditions are natural. This is a spline of the transformed f, not a piecewise-linear fit of Cp. Table4, printed p15 / PDF p16, supplies numerical checks, including Cp(298.15K)=50.16 J/(mol K). Solid enthalpy increments follow from integrating the defined heat capacity. Printed p12 discusses empirical accuracy: the roughly .3% statement applies to 300..800K; do not apply it automatically below 300K. This representation differs from the older JANAF value 50.509 at 298.15K. Keep one declared thermodynamic reference or account for differences.

Archer, Part II: NaCl(aq), NaCl.2H2O(cr), and phase equilibria, JPCRD21,793-829 (1992), DOI 10.1063/1.555915.
https://srd.nist.gov/jpcrdreprint/1.555915.pdf
Printed p796 / PDF p5: Eq2 explicitly uses Part I's solid heat-capacity integrals, Tr=298.15K, pr=.1MPa. Section4.1, printed pp797-801 / PDF pp6-10, supplies the modified ion-interaction model. Eq9 is relative apparent enthalpy; Eq12 is apparent molar heat capacity; Eq20 defines an apparent property. Eqs21-22 retain the reference solution at mr=6 mol/kg; Eqs32-38 define the temperature/pressure functions; Table2 gives coefficients. Eq38's heat-capacity scale is 1 kJ/(mol K), not 1 J/(mol K). Table2's anhydrous -9.040721 kJ/mol parameter is a Gibbs-energy anchor, not a dissolution-enthalpy anchor. Eq2's solid entropy at Tr is 72.2653 J/(mol K); the solute entropy in Table2 is 115.5108 J/(mol K). Check conversion to enthalpy rather than substituting G for H. Blank coefficient entries are omitted terms. Pages798-801 have been rendered for inspecting symbols and signs. Original model uses Hill's water EOS and the dielectric relation of Archer/Wang (references3,14), with Debye-Huckel definitions from Bradley/Pitzer (reference15). Substituting another water representation is a model change to document. Validation tables and phase-equilibrium section5 are included in the full article. The fitted data span approximately250..600K; physical liquid-phase validity still needs checking at the chosen pressure/composition.

Operator boundaries for use

The source pages, table units, selected Parker entries and Part I knot values were visually inspected. The full aqueous EOS has not been implemented or numerically certified by the operator. No grid evaluation, extremum, certified interval enclosure, pure-water/brine boiling interval or uniform capacity bound is supplied. Implement and derive the material model from the primary equations, retain your calculation provenance, and prove the consequences needed in Lean. State any indispensable missing primary coefficient explicitly rather than selecting a favorable sign or treating sparse table samples as bounds.

Use consistent definitions of isothermal dissolution from same-temperature reactants, the stored solid's sensible enthalpy, absolute apparent heat capacity and relative infinite-dilution corrections. A sparse-temperature secant is not a local heat-capacity law. Phase boundaries must follow from pressure and composition; do not assume the brine boiling point is below100C. Keep apparatus assumptions separate from property evidence. This literature response does not approve a model or conclusion.
{
  "created_utc": "2026-11-18T00:49:25.405175+00:00",
  "purpose": "Primary material-property literature; no experiment, timing recommendation, peer result or certified EOS bound supplied",
  "sources": [
    {
      "file": "archer-1992-part1-crystalline.pdf",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555913.pdf",
      "doi": "10.1063/1.555913",
      "bytes": 1916292,
      "sha256": "c3d73a33e8e9f7cbc041ef32a3cc68d6f8973aeb285e5b248c97920c971681c8"
    },
    {
      "file": "archer-1992-part2-solution.pdf",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555915.pdf",
      "doi": "10.1063/1.555915",
      "bytes": 3393563,
      "sha256": "a814e0cee1b80352619a12324e4355d4253a50ca9fcc86be26b3d32865c098f5"
    },
    {
      "file": "parker-1965-nsrds2.pdf",
      "url": "https://nvlpubs.nist.gov/nistpubs/Legacy/NSRDS/nbsnsrds2.pdf",
      "doi": "10.6028/NBS.NSRDS.2",
      "bytes": 5496010,
      "sha256": "6e5a30917ba61a22e542766195b71e0b3cfd7463a0c6ae11b97ffdd1f8b88743"
    }
  ],
  "visual_inspection": [
    "part1-eqs.png",
    "part1-knots.png",
    "part2-coefficients.png",
    "part2-definitions.png",
    "part2-enthalpy-capacity.png",
    "part2-temperature-functions.png",
    "parker-table-X.png",
    "parker-heat-capacity.png",
    "parker-enthalpy-infinity.png"
  ],
  "retrieval_notes": [
    "Initial plain urllib request returned HTTP403; successful retry used a normal browser user-agent with TLS verification enabled.",
    "A guessed NIST mirror filename returned an unrelated PDF and was discarded. Part II was fetched again from the verified DOI reprint URL and its title/text checked."
  ],
  "files": {
    "READING-NOTES.txt": {
      "sha256": "9dcfa3c0855752fd4e39331c21f32c7732b9a3d05f80840fecf17de4e810045c",
      "bytes": 4890
    },
    "archer-1992-part1-crystalline.pdf": {
      "sha256": "c3d73a33e8e9f7cbc041ef32a3cc68d6f8973aeb285e5b248c97920c971681c8",
      "bytes": 1916292
    },
    "archer-1992-part1-crystalline.txt": {
      "sha256": "8c297d73c003642be355f6911d99ed618b3dd09e59c7573fd522fb7b1e35a81c",
      "bytes": 118876
    },
    "archer-1992-part2-solution.pdf": {
      "sha256": "a814e0cee1b80352619a12324e4355d4253a50ca9fcc86be26b3d32865c098f5",
      "bytes": 3393563
    },
    "archer-1992-part2-solution.txt": {
      "sha256": "31ee833327932f95837944fe7f2d3b96ea436039a3ce1d8b2fe131f631cb1dab",
      "bytes": 278447
    },
    "archer-solid-knots.csv": {
      "sha256": "ed9d5f49ff75434e01385322878f4bfd1881ddccaf99c20f47210e859466eeb7",
      "bytes": 158
    },
    "parker-1965-nsrds2.pdf": {
      "sha256": "6e5a30917ba61a22e542766195b71e0b3cfd7463a0c6ae11b97ffdd1f8b88743",
      "bytes": 5496010
    },
    "parker-1965-nsrds2.txt": {
      "sha256": "f9903f6e36366b1b71da1d20447b44cb6acfab069383ca75be475afc16ad7b0b",
      "bytes": 538802
    },
    "parker-apparent-heat-capacity.csv": {
      "sha256": "2ffdd877837ac12e182b59a73ba683535773f9c91f4f1e9913c5b816beb9b986",
      "bytes": 356
    },
    "parker-enthalpy-infinity.png": {
      "sha256": "0d824a7d691c99c708e2d98c686b140d46d63d822f47488795e99311d6c7404c",
      "bytes": 1455467
    },
    "parker-heat-capacity.png": {
      "sha256": "3104996970dd6a1ae6e0e4e1e16cac91ca85fb7bdd647bc8368a61d00e6aaa93",
      "bytes": 421070
    },
    "parker-relative-enthalpy-25C.csv": {
      "sha256": "4ae523c9b02c95afb672c683d1844995935f9bef10497cfa81a3e67e6b5fc9fc",
      "bytes": 103
    },
    "parker-table-X.png": {
      "sha256": "b499610ea47b5eddac5707d3a536779b5a7288f6bc501d15841a37843dd4180b",
      "bytes": 660566
    },
    "part1-eqs.png": {
      "sha256": "8c32d07adbcb76f53cd8c11f2770ec4100411405f7afc08f4caabbee25435082",
      "bytes": 223114
    },
    "part1-knots.png": {
      "sha256": "b6d17dccdcebd93775a3c9db0273cd6bb82694e877ed2b1486d75f6da211e472",
      "bytes": 262165
    },
    "part2-coefficients.png": {
      "sha256": "30d42e111e9e266e7b1ae91dd3177242b2a123405f23bd3e47f519e245aa74ca",
      "bytes": 150936
    },
    "part2-definitions.png": {
      "sha256": "d981636acf70a4008e9a1f43337bc7ee661dcda010c6efe7863e5bcb9fc172f5",
      "bytes": 199707
    },
    "part2-enthalpy-capacity.png": {
      "sha256": "94d2669dca823195bd66cd631eb8373d59e6de52dd0fc6f2fa616954b100579d",
      "bytes": 156604
    },
    "part2-temperature-functions.png": {
      "sha256": "609ecb83e48ba810ee139826a099ae813143bc35138068741881c0c5c9b5ed06",
      "bytes": 180657
    }
  }
}
/work/evidence:
cycle4
cycle5
cycle6

/work/evidence/cycle4:
research-notes.txt

/work/evidence/cycle5:
check-1.txt
check-2.txt
check-3.txt
check-4.txt
evaluate_material_model.py
extract-trace-1.txt
extract-trace-2.txt
extracted-conclusion-repr.txt
local-lean-1.log
local-lean-2.log
local-lean-3.log
local-lean-4.log
material-model-calculation.log
material-model-evaluation.json
original-conclusion-repr.txt
revision-trace.txt
trace-extracted.json
trace-extracted.lean
trace-extraction-result.txt
trace_extraction.py

/work/evidence/cycle6:
request-output.txt
request-question.txt
revision-notes.txt
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:42:43.075074+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '160,270p' /work/inputs/material-literature-002/archer-1992-part2-solution.txt; sed -n '300,780p' /work/inputs/material-literature-002/archer-1992-part2-solution.txt; cat /work/evidence/cycle6/revision-notes.txt; cat /work/evidence/cycle5/revision-trace.txt; for x in /work/checks/*/verdict.json; do echo \\\"\"'$x\"; head -12 \"$x\"; done'"
}
shell output · exit 0
https://doi.org/10.1063/1.555915

Cycle 6: review and evidence request; no revised candidate submitted yet.

Read the task-local history, cycle5 report/proof/calibration, current human-feedback.json, material response f7c987a52391410bb035542305825b3f and primary-source excerpts. Preserved rejected files in history/cycle6-start/. The last actual check is checks/0a52ddc3554b4e10b6c5b477fceb0093: proved, complete independent extraction and kernel recheck. Earlier cycle5 checks failed extraction identity and one proof elaboration; those were fixed by explicit casts and proof-local normalization. These diagnostics do NOT address the material-model defects identified by the subsequent human rejection. No human approval is inferred.

The principal scientific defect is treating the 20-to-100 C enthalpy secant as the actual capacity increment throughout the interval. Neither endpoint matching nor sampled residuals validate that replacement. Also withdraw use of unbounded composition interpolation, standard dissolution-enthalpy interpolation/extrapolation and a constant solid heat capacity as a sufficient physical derivation. The original generic constant-capacity proofs remain conditional mathematics, not a temperature-dependent NaCl result.

Proposed temperature-dependent formulation (derived here on paper, NOT yet a Lean theorem): let U(T) be water+pot enthalpy and V(T) final brine+pot enthalpy on the same reference, and K the enthalpy of the 10 g solid held at 20 C. Define D(T)=V(T)-U(T)-K. Adiabatic instantaneous addition at water temperature x gives V(z(x))=U(x)+K. Positive final capacity V'(T)>0 gives sign(x-z(x))=sign(D(x)) wherever both states are in the liquid domain. The shared law N(T)=W-k(T-20) then implies N(z)-N(x)=k(x-z), without presuming its sign.

For elapsed time tau(x)=integral from 20 to x of U'(T)/N(T) dT + integral from z(x) to B of V'(T)/N(T) dT, implicit differentiation gives V'(z)*z'=U'(x). Hence tau'=U'(x)*(1/N(x)-1/N(z)). Local brine capacity cancels from the timing derivative, but its positivity remains essential for the mixing map and feasibility. Thus uniform D>0 would imply earliest addition under the accepted loss law; D<0 or sign changes require different analysis. No sign or optimum is adopted in advance. This generalization preserves true temperature dependence rather than fitting a constant S. The common salted heating segment above every possible z cancels from comparisons; its heat capacity need not be extrapolated from a 100 C fit merely to determine the comparison, although final-stage existence/phase validity still needs justification.

Reference conversion: per mole, D_mol(T)=h_diss(T,m)+[h_cr(T)-h_cr(20)], where h_diss is the integral isothermal dissolution enthalpy at that same T and final molality. D_mol'(T)=C_app(T,m), the absolute apparent solution-minus-water heat capacity, not dissolution Cp difference and not relative apparent capacity. D(total)=n*D_mol. The unchanged pot cancels from D, but contributes to U' and V'. The density-based mass must be derived as (1 L)*(1000 cm^3/L)*(.99820675 g/cm^3)*(1 kg/1000 g); m=(10 g)/(58.443 g/mol)/mass. The concentration is not a new independent input.

Primary-source issue found on rereading: Partanen2025 Eq22 uses C_infinite(t)=-8-2t J/(mol K), derived from a solubility-based enthalpy model. Section3.2 (printed296-297) explicitly notes disagreements among absolute baselines and calls its own -58 at25 C less realistic than -84 from Abraham/Marcus. Criss-Cobble-based baseline is a separate alternative. We cannot splice Eq22 into a Criss-Cobble enthalpy curve and retain thermodynamic consistency. These source disagreements make it inappropriate to demand a positive D bound without checking which consistent model supports it.

Archer1992 PartII section2 (printed796, PDFpage4) uses integrals of the NaCl(cr) spline in Ref4, Archer1992 PartI, JPCRD21,1, DOI10.1063/1.555913. That spline is not in the supplied PartII bundle. PartII equations20-22,32-38 describe internally consistent aqueous properties, with coefficients in Table2; OCR is inadequate for formal parameter entry without image verification. PartI was located through the official NIST reprint index: https://srd.nist.gov/jpcrdreprint/1.555913.pdf . No coefficients from its unseen pages have been used. Native source consultation only; no earlier solution, other agent, paid service or authentication material consulted.

Next step: request a verified consistent empirical material representation (or source evaluation with reproducible equations and justified interval/error treatment). Then formalize its derived bounds and the variable-capacity timing theorem. No new check is claimed for these handwritten derivations, and the rejected candidate remains historical pending evidence.
Cycle 5 lineage, 2026-11-17 UTC

Reviewed supplied human feedback and cycle-3 accepted mathematical check (8ce875bbeedf40f384474d008e4dfa66), as well as the older preserved extraction failure f49ea96bd5de45babf8f3c699ba15e09. Cycle-3 scientific answer remained rejected. Incorporated operator material response f7c987a52391410bb035542305825b3f and read its original source text/PDF bundle; no previous solution or external agent was consulted.

Kept the previously selected 10 g dry crystalline NaCl case. Calibrated a 20-to-100 C effective enthalpy secant from the supplied dissolution enthalpies and concentration correction. Disclosed concentration interpolation, standard-enthalpy extrapolation, solid Cp approximation, affine approximation and apparatus conditions. Computed sampled residuals; did not reinterpret them as uniform validation. Retained the generic signed-capacity timing theorem and energy derivations, added one direct physical-case conclusion.

Local command local-lean-1.log records a wrong guessed executable location, then local-lean-2.log records actual parsing/layout and rewriting errors. The final let binding needed a semicolon so the unary-minus body could not be parsed as continued subtraction; the mixed-temperature lower-bound proof needed rewriting the initial-temperature definition in the goal as well as its hypothesis. No mathematical assumption changed in these repairs. local-lean-3.log subsequently compiled without errors (warnings are retained).

Protocol check 1: checks/3366e6e934024e17b8832b7253fbd31c; lean_exit=0, standalone extraction compiles, every model dependency faithful, but final conclusion identity false. Raw result is check-1.txt. Replaced only the theorem's scientific decimal 100.1 by the exactly equivalent (1001 / 10 : real) to avoid generated proof identity differences during pretty-print extraction; no model or physical bound changed. Protocol check 2 is recorded separately in check-2.txt. Its actual verdict, not local compilation, determines verification status. No human approval is inferred.

Protocol check 2 also compiled but failed conclusion identity, so replacing only the decimal was insufficient. Instrumented the installed extractor using the run's pre-existing tracing method, preserving both raw repr traces. Differences identify Real numeric literals' auxiliary proof arguments (original theorem inline, extracted definition lifted). Protocol check 3 replaced all >=2 Real literals in the public theorem with exact natural-to-real casts and reused initialTemperature=20. It then reported real proof elaboration errors in lean.log because arithmetic tactics did not normalize those casts/temperature references automatically. Added proof-local normalization of casts and initialTemperature only. local-lean-4.log compiles this revised proof successfully. Protocol check 4 records the actual independent result. No scientific bound, assumption, data point or conclusion changed during these representation repairs.
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/verdict.json
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T23:45:21.072186+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean",
    "conclusions": [
/work/checks/19e916da3a2f417381acb479d8151af9/verdict.json
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T14:22:00.296935+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean",
    "conclusions": [
/work/checks/3366e6e934024e17b8832b7253fbd31c/verdict.json
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:41:59.788687+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/verdict.json
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:44:19.408976+00:00",
  "lean_exit": 1,
  "error": "Lean, kernel recheck or axiom audit failed; see lean.log"
}
/work/checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T15:48:51.378080+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean",
    "conclusions": [
/work/checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-16T18:27:31.048579+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean",
    "conclusions": [
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:25:46.169042+00:00",
  "lean_exit": 1,
  "error": "Lean, kernel recheck or axiom audit failed; see lean.log"
}
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-16T18:26:03.961421+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/verdict.json
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:42:43.075074+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '390,650p' /work/inputs/material-literature-002/archer-1992-part2-solution.txt; sed -n '2100,2160p' /work/inputs/material-literature-002/archer-1992-part2-solution.txt; find /work/inputs -maxdepth 2 -type f -name '*.txt'\""
}
shell output · exit 0
https://doi.org/10.1063/1.555915

/work/inputs/material-literature-002/READING-NOTES.txt
/work/inputs/material-literature-002/archer-1992-part1-crystalline.txt
/work/inputs/material-literature-002/archer-1992-part2-solution.txt
/work/inputs/material-literature-002/parker-1965-nsrds2.txt
/work/inputs/material-evidence-001/nist-webbook-nacl.txt
/work/inputs/material-evidence-001/iapws95-2018.txt
/work/inputs/material-evidence-001/archer-1992-nacl-water.txt
/work/inputs/material-evidence-001/nist-water-density.txt
/work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt
/work/inputs/material-evidence-001/partanen-2023-enthalpy.txt
/work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt
/work/inputs/material-evidence-001/nist-janaf-nacl-solid.txt
assistant
The latest Lean check passed, but the subsequent human review rejected the material approximation. That proof does not establish a timing recommendation for NaCl. The new Archer bundle supplies the solid-salt model; the aqueous model also requires water and dielectric-property relations cited separately. I’m checking those dependencies before drawing a conclusion.
web_search input
{
  "query": "Archer Wang 1990 dielectric constant water Debye Huckel limiting law slopes 19 371 NIST pdf ...",
  "action": {
    "type": "search",
    "queries": [
      "Archer Wang 1990 dielectric constant water Debye Huckel limiting law slopes 19 371 NIST pdf",
      "Hill 1990 unified fundamental equation thermodynamic properties H2O 19 1233 NIST pdf",
      "Bradley Pitzer 1979 1983 Debye Huckel parameters dielectric water 1599 3798"
    ]
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn0search12",
      "snippet": "The Dielectric Constant of Water and Debye-Hückel Limiting Law Slopes ... Keywords: Debye-Hückel limiting law, dielectric constant, thermodynamic properties of aqueous electrolytes, water. ... ©1990",
      "title": "PšP",
      "url": "https://srd.nist.gov/JPCRD/jpcrd383.pdf"
    },
    {
      "type": "text_result",
      "domain": "pubs.acs.org",
      "ref_id": "turn0search0",
      "snippet": "Dielectric properties of water and Debye-Hueckel parameters to 350.degree.C and 1 kbar ... Bradley; ... Pitzer ... (1979) 83 (12): 1599–1603.",
      "title": "Thermodynamics of electrolytes.  12.  Dielectric properties of water and Debye-Hueckel parameters to 350.degree.C and 1 kbar",
      "url": "https://pubs.acs.org/doi/10.1021/j100475a009"
    },
    {
      "type": "text_result",
      "domain": "inis.iaea.org",
      "ref_id": "turn0search1",
      "snippet": "Dielectric properties of water and Debye--Hueckel parameters to 3500C and 1 kbar ... * Bradley, D.J. ... * Pitzer, K.S. ... 1599-1603",
      "title": "Thermodynamics of electrolytes. 12. Dielectric properties of water and Debye--Hueckel parameters to 3500C and 1 kbar",
      "url": "https://inis.iaea.org/records/jfabw-16a07"
    },
    {
      "type": "text_result",
      "domain": "kitchingroup.cheme.cmu.edu",
      "ref_id": "turn0search2",
      "snippet": "* Bradley, D.J., and Pitzer, K.S. (1979). ... Dielectric properties of water and Debye–Hückel parameters to 350 °C and 1 kbar. Journal of Physical Chemistry",
      "title": "References - discopt-speciation",
      "url": "https://kitchingroup.cheme.cmu.edu/discopt-speciation/references/"
    },
    {
      "type": "text_result",
      "domain": "agupubs.onlinelibrary.wiley.com",
      "ref_id": "turn0search3",
      "snippet": "Coefficients for Dielectric Constant for Water From Bradley and Pitzer (1979) ... where Image: urn:x-wiley:21699313:media:jgrb55376:jgrb55376-math-0062 and Image: urn:x-wiley:21699313:media:jgrb55376:",
      "title": "Microscale Mechanical-Chemical Modeling of Granular Salt: Insights for Creep",
      "url": "https://agupubs.onlinelibrary.wiley.com/doi/full/10.1029/2021JB023112"
    },
    {
      "type": "text_result",
      "domain": "escholarship.org",
      "ref_id": "turn0search13",
      "snippet": "DIELECTRIC PROPERTIES OF WATER AND DEBYE-HOCKEL PARAMETERS TO 350' AND 1 KBAR. ... Bradley and Kenneth S. Pitzer ... JAN 29 1979",
      "title": "Lawrence Berkeley National Laboratory",
      "url": "https://escholarship.org/content/qt0mt9n7cj/qt0mt9n7cj.pdf"
    },
    {
      "type": "text_result",
      "domain": "pascal-francis.inist.fr",
      "ref_id": "turn0search4",
      "snippet": "\"O:12:\\\"IstexOpenUrl\\\":35:{s:10:\\\"\\u0000*\\u0000openUrl\\\";N;s:6:\\\"\\u0000*\\u0000fmt\\\";s:7:\\\"journal\\\";s:6:\\\"\\u0000*\\u0000doi\\\";s:16:\\\"10.1063\\/1.555853\\\";s:6:\\\"\\u0000*\\u0000pii\\\";s:0:\\\"\\\";s:7:\\\"\\u0000*\\",
      "title": "The dielectric constant of water and Debye-Hückel limiting law slopes",
      "url": "https://pascal-francis.inist.fr/vibad/index.php?action=getRecordDetail&idt=6908012"
    },
    {
      "type": "text_result",
      "domain": "nvlpubs.nist.gov",
      "ref_id": "turn0search14",
      "snippet": "The Debye-Hückel parameter A\\_φ is a function of the properties of pure water only: ... where N\\_0 is Avogadro's number, d\\_w is the density of",
      "title": "Chemical thermodynamics in steam power cycles data requirements: proceedings of a workshop held at the National Bureau of Standards, Gaithersburg, Maryland February 8-9, 1983",
      "url": "https://nvlpubs.nist.gov/nistpubs/Legacy/IR/nbsir85-3205.pdf"
    },
    {
      "type": "text_result",
      "domain": "github.com",
      "ref_id": "turn0search5",
      "snippet": "# water_permittivity_bradley_pitzer_1979.py ... Relative permittivity of water (dielectric constant) ... properties of water and Debye--Hueckel parameters to 350/sup ... 1599-1603,",
      "title": "chempy/chempy/properties/water_permittivity_bradley_pitzer_1979.py at master · bjodah/chempy · GitHub",
      "url": "https://github.com/bjodah/chempy/blob/master/chempy/properties/water_permittivity_bradley_pitzer_1979.py"
    },
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn0search15",
      "snippet": "The use of this formulation for fluid H₂O has been endorsed by IAPS for temperatures between 0 and 1000 °C and pressures ranging from zero",
      "title": "# INTERNATIONAL FORMULATIONS FOR THE THERMODYNAMIC PROPERTIES OF WATER",
      "url": "https://srd.nist.gov/JPCRD/jpcrd290.pdf"
    },
    {
      "type": "text_result",
      "domain": "scispace.com",
      "ref_id": "turn0search6",
      "snippet": "Bradley,Kenneth S. Pitzer +1 more ... 83, Iss: 12, pp 1599-1603 ... TL;DR: In this article, an equation for the representation of the dielectric constant",
      "title": "Thermodynamics of electrolytes. 12. Dielectric properties of water and Debye-Hueckel parameters to 350.degree.C and 1 kbar",
      "url": "https://scispace.com/papers/thermodynamics-of-electrolytes-12-dielectric-properties-of-1ubbrivng9"
    },
    {
      "type": "text_result",
      "domain": "scispace.com",
      "ref_id": "turn0search7",
      "snippet": "Abstract: Experimental values of the dielectric constant of water suggest that, for temperatures greater than 400 K, the integral in the Kirkwood dielectric‐constant equation, which",
      "title": "The Dielectric Constant of Water and Debye‐Hückel Limiting Law Slopes",
      "url": "https://scispace.com/papers/the-dielectric-constant-of-water-and-debye-huckel-limiting-1yjhca5ts2?citations_page=99"
    },
    {
      "type": "text_result",
      "domain": "oamonitor.ireland.openaire.eu",
      "ref_id": "turn0search8",
      "snippet": "A Unified Fundamental Equation for the Thermodynamic Properties of H2O description Publication keyboard_double_arrow_right Article 01 Sep 1990 English Publisher:AIP Publishing Journal:Journal of Physi",
      "title": "A Unified Fundamental Equation for the Thermodynamic Properties of H2O",
      "url": "https://oamonitor.ireland.openaire.eu/national/search/publication?pid=10.1063%2F1.555868"
    },
    {
      "type": "text_result",
      "domain": "eurekamag.com",
      "ref_id": "turn0search9",
      "snippet": "# The dielectric constant of water and Debye-Hückel limiting law slopes ... #### Journal of Physical and Chemical Reference Data 19(2): 371-411 ... 2007: Static",
      "title": "The dielectric constant of water and Debye-Hückel limiting law slopes",
      "url": "https://eurekamag.com/research/078/263/078263846.php"
    },
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn0search16",
      "snippet": "Only three papers were concerned with the effect of pressure, all of them revealing a small positive slope at room temperature. ... ⁵ The latter",
      "title": "H®M",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555977.pdf"
    },
    {
      "type": "text_result",
      "domain": "www.rdocumentation.org",
      "ref_id": "turn0search10",
      "snippet": "Archer, D. ... M., 1990. The dielectric constant of water and Debye-Huckel limiting law slopes. ... Data, 19, 371-411. http://www.nist.gov/srd/PDFfiles/jpcrd383.pdf",
      "title": "water function - RDocumentation",
      "url": "https://www.rdocumentation.org/packages/CHNOSZ/versions/0.9-3/topics/water"
    },
    {
      "type": "text_result",
      "domain": "www.cantera.org",
      "ref_id": "turn0search11",
      "snippet": "Bradley-Pitzer equation for the dielectric constant of water as a function of temperature and pressure. ... The A_Debye expression appears on the top of the",
      "title": "Cantera: WaterProps Class Reference",
      "url": "https://www.cantera.org/3.1/cxx/d2/db1/classCantera_1_1WaterProps.html"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search17",
      "snippet": "Bibcode:1978MTA.....9..397L. doi:10.1007/BF02646390. ... ; Pitzer, Kenneth S. ... Dielectric properties of water and Debye-Hueckel parameters to 350.degree.C and 1 kbar\". ... 83 (12): 1599–1603. doi:1",
      "title": "Daniel J. Bradley",
      "url": "https://en.wikipedia.org/wiki/Daniel_J._Bradley"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search18",
      "snippet": "Pitzer equations ... ${\\displaystyle PV=RT+BP+CP^{2}+DP^{3}\\dots }$ ... The Debye-Hückel theory was based on the assumption that each ion was surrounded by a spherical \"cloud\" or",
      "title": "Pitzer equations",
      "url": "https://en.wikipedia.org/wiki/Pitzer_equations"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search19",
      "snippet": "The Debye–Hückel theory was proposed by Peter Debye and Erich Hückel as a theoretical explanation for departures from ideality in solutions of electrolytes and plasmas.",
      "title": "Debye–Hückel theory",
      "url": "https://en.wikipedia.org/wiki/Debye%E2%80%93H%C3%BCckel_theory"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search20",
      "snippet": "* Archer, G. ... (1990). \"The Dielectric Constant of Water and Debye-Hückel Limiting Law Slopes\". ... 19 (2): 371–411. doi:10.1063/1.555853. ... \"Dielectric properties of CaCu_{3}Ti_{4}O_{12}",
      "title": "Relative permittivity",
      "url": "https://en.wikipedia.org/wiki/Relative_permittivity"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search21",
      "snippet": "Further comprehensive authoritative data can be found at the NIST Chemistry WebBook page on thermophysical properties of fluids. ... liquid: | ν_{1} = 3280, |",
      "title": "Water (data page)",
      "url": "https://en.wikipedia.org/wiki/Water_%28data_page%29"
    },
    {
      "type": "text_result",
      "domain": "en.wikipedia.org",
      "ref_id": "turn0search22",
      "snippet": "In an electrolyte or a colloidal suspension, the Debye length for a monovalent electrolyte is usually denoted with symbol κ^{−1} ${\\displaystyle \\kappa ^{-1}={\\sqrt {\\frac {\\varepsilon",
      "title": "Debye length",
      "url": "https://en.wikipedia.org/wiki/Debye_length"
    },
    {
      "type": "text_result",
      "domain": "arxiv.org",
      "ref_id": "turn0academia23",
      "snippet": "Date: Tue Dec 17 16:20:16 2019 In view of the vital role of water in chemical and physical processes, an exact knowledge of its dielectric",
      "title": "Full-spectrum high resolution modeling of the dielectric function of water",
      "url": "https://arxiv.org/abs/1912.08118"
    },
    {
      "type": "text_result",
      "domain": "arxiv.org",
      "ref_id": "turn0academia24",
      "snippet": "The dielectric spectrum of liquid water, $10^{4} - 10^{11}$ Hz, is interpreted in terms of diffusion of charges, formed as a result of self-ionization of",
      "title": "Proton Electrodynamics in Liquid Water",
      "url": "https://arxiv.org/abs/1302.5048"
    },
    {
      "type": "text_result",
      "domain": "arxiv.org",
      "ref_id": "turn0academia25",
      "snippet": "Title: Water and Ice Dielectric Spectra Scaling at 0 °C ... In this picture, the Debye relaxations, centered at 1/{\\tau}_W ~ 20 GHz (in water)",
      "title": "Water and Ice Dielectric Spectra Scaling at 0 °C",
      "url": "https://arxiv.org/abs/1308.1229"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc \"mkdir -p /work/history/cycle7-start /work/evidence/cycle7; cp /work/Model.lean /work/report.txt /work/candidate.json /work/history/cycle7-start/; python - <<'PY'\nimport urllib.request,pathlib,hashlib,json,subprocess\np=pathlib.Path('/work/evidence/cycle7')\nurls={'archer-wang-1990.pdf':'https://srd.nist.gov/JPCRD/jpcrd383.pdf','hill-1990.pdf':'https://srd.nist.gov/jpcrdreprint/1.555868.pdf'}\nrecords=[]\nfor f,u in urls.items():\n try:\n  req=urllib.request.Request(u,headers={'User-Agent':'Mozilla/5.0'})\n  b=urllib.request.urlopen(req,timeout=40).read()\n  (p/f).write_bytes(b)\n  records.append(dict(file=f,url=u,bytes=len(b),sha256=hashlib.sha256(b).hexdigest()))\n  subprocess.run(['pdftotext','-layout',str(p/f),str(p/f.replace('.pdf','.txt'))],check=True)\n except Exception as e: records.append(dict(file=f,url=u,error=str(e)))\n(p/'source-retrieval.json').write_text(json.dumps(records,indent=2))\nprint(json.dumps(records,indent=2))\nPY\""
}
shell output · exit 0
[
  {
    "file": "archer-wang-1990.pdf",
    "url": "https://srd.nist.gov/JPCRD/jpcrd383.pdf",
    "bytes": 3848969,
    "sha256": "b4a53a4e42691c9c78f13095489603c7bee16f36b2dca3f6fd9992b186a58954"
  },
  {
    "file": "archer-wang-1990.pdf",
    "url": "https://srd.nist.gov/JPCRD/jpcrd383.pdf",
    "error": "[Errno 2] No such file or directory: 'pdftotext'"
  },
  {
    "file": "hill-1990.pdf",
    "url": "https://srd.nist.gov/jpcrdreprint/1.555868.pdf",
    "bytes": 3145598,
    "sha256": "4f41ec7fd17a1f62887ec876b556ef66c617ae655745085acbed5860fa1766c8"
  },
  {
    "file": "hill-1990.pdf",
    "url": "https://srd.nist.gov/jpcrdreprint/1.555868.pdf",
    "error": "[Errno 2] No such file or directory: 'pdftotext'"
  }
]
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/lean-env.sh; ls /work/evidence/cycle7; cat /work/inputs/material-literature-002/archer-solid-knots.csv; cat /work/inputs/material-literature-002/parker-apparent-heat-capacity.csv'"
}
shell output · exit 0
export LEAN_PATH=/harness/.lake/packages/plausible/.lake/build/lib/lean:/harness/.lake/packages/proofwidgets/.lake/build/lib/lean:/harness/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/harness/.lake/packages/mathlib/.lake/build/lib/lean:/harness/.lake/packages/aesop/.lake/build/lib/lean:/harness/.lake/packages/batteries/.lake/build/lib/lean:/harness/.lake/packages/importGraph/.lake/build/lib/lean:/harness/.lake/packages/Qq/.lake/build/lib/lean
archer-wang-1990.pdf
hill-1990.pdf
source-retrieval.json
T_K,f_dimensionless
0,20.4174
5,18.6946
7.5,18.2037
15,15.2827
20,13.2900
45,8.12535
90,5.77101
220,5.62745
400,7.04825
550,7.41175
800,5.08930
1100,-8.76890
molality_mol_per_kg,Phi_C_15C_cal_per_mol_K,Phi_C_20C_cal_per_mol_K,Phi_C_25C_cal_per_mol_K,Phi_C_30C_cal_per_mol_K
0,-25.2,-23.3,-21.5,-20.1
0.1388,-21.4,-19.8,-18.2,-16.9
0.1850,-20.5,-19.0,-17.5,-16.2
0.2775,-19.0,-17.5,-16.3,-15.1
0.3700,-17.7,-16.4,-15.2,-14.1
0.5551,-15.5,-14.8,-13.4,-12.5
0.7401,-13.6,-12.6,-11.7,-10.9
1.1101,-10.4,-9.6,-8.8,-8.2
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport importlib.util\nfor m in ['fitz','pypdf','scipy','numpy','mpmath','iapws','CoolProp']:\n print(m, bool(importlib.util.find_spec(m)))\nPY\""
}
shell output · exit 0
fitz False
pypdf False
scipy False
numpy False
mpmath False
iapws False
CoolProp False
shell input
{
  "command": "/usr/bin/bash -lc \"ls /usr/bin | head -40; ls -la /harness; ls /opt; command -v python; command -v lean; find / -maxdepth 3 -name '*python*' -type f 2>/dev/null | head -20\""
}
shell output · exit 0
[
apt
apt-cache
apt-cdrom
apt-config
apt-get
apt-mark
arch
awk
b2sum
base32
base64
basename
basenc
bash
bashbug
c_rehash
captoinfo
cat
chage
chcon
chfn
chgrp
chmod
choom
chown
chrt
chsh
cksum
clear
clear_console
cmp
comm
cp
csplit
cut
dash
date
dd
deb-systemd-helper
total 24
drwxr-xr-x 4 root root 4096 Nov 18 00:51 .
drwxr-xr-x 1 root root 4096 Nov 18 00:51 ..
drwxr-xr-x 3 root root 4096 Nov 18 00:51 .lake
-rwxrwxr-x 1 1001 1001  689 Nov 16 18:09 entrypoint.sh
-rw-rw-r-- 1 1001 1001   25 Nov 16 18:09 lean-toolchain
drwxr-xr-x 2 root root 4096 Nov 18 00:51 src
lean
/usr/local/bin/python
web_search input
{
  "query": "https://srd.nist.gov/JPCRD/jpcrd383.pdf",
  "action": {
    "type": "open_page",
    "url": "https://srd.nist.gov/JPCRD/jpcrd383.pdf"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn1view0",
      "snippet": "Total lines: 0",
      "title": "PšP",
      "url": "https://srd.nist.gov/JPCRD/jpcrd383.pdf"
    },
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn1view1",
      "snippet": "Total lines: 3580",
      "title": "˻Q",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555868.pdf"
    }
  ]
}
web_search input
{
  "query": "",
  "action": {
    "type": "other"
  }
}
web_search output
{
  "results": []
}
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\nimport re,zlib\nb=Path('/work/evidence/cycle7/archer-wang-1990.pdf').read_bytes()\nfor i,m in enumerate(re.finditer(rb'(\\\\d+)\\\\s+0\\\\s+obj(.*?)endobj',b,re.S)):\n d=m[2]\n if b'/Subtype /Image' in d:\n  print(m[1].decode(),d[:250])\n  if i>80:break\nPY\""
}
shell output · exit 0
47 b'\r<< /Type /XObject /Subtype /Image /Name /im21 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 46 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n\xff\xff\xff\xc8\x0f\xb7\x14\xe3\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe@X\tG\xff\xff\xff\xff\xff\xff\xff\xff\xff\x90\x15\x12\x0b (\r\x91\x82\x9a\x86'
49 b'\r<< /Type /XObject /Subtype /Image /Name /im22 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 48 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n,\x82@\xe6\xa1\x94\x81KL\xa4SP\x84HBC#\x88E\x83,\xd0B\x18\xa6b\x91\x19\xa0\xa7QO\x88U\x88C\x10\xa8\x0c\xc2q\x0f\x82'
51 b'\r<< /Type /XObject /Subtype /Image /Name /im23 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 50 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n\xf9\x01\xf9\x16/]FYI)eR\x19\xd9\x07\xce\xe6\x14\xed&d\x11\x99\x0b8M\x06v0T\xef8\xe9\x17\x9f\xcbV\xae.\x93oX\xdf'
53 b'\r<< /Type /XObject /Subtype /Image /Name /im24 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 52 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n 4\xc1\x11\xb1Ma\x08\xa9\x19\x15\x11\x03\x19\xacgpEL\xb5\xb6\xbe\xba\xfc?\xdb\xff\xdf\xfb\xf9\x01\xb0*}\xe6\x05#\x11\xa0\xce\x91\x17\x19'
55 b'\r<< /Type /XObject /Subtype /Image /Name /im25 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 54 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n 0\xcc9\x1c\x10\xe0\x10`\xcc\xcc\xe00NGA\x99\x8c\xf1\x9a\x0c\xd0\x8c\xc6f\x1a\np\xe7\x053#@\\\xd6\x0c\x19\x91\x99\x9a\x11\xa1\x99'
57 b'\r<< /Type /XObject /Subtype /Image /Name /im26 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 56 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n,\xa2FC3\xe4H289\xe1Hb\x1d\x0c\x9c\xc9\xc8\x86e\xc1\x0e\nL\x19\xa1\x1e\r\x07Q\x93\x99\x02gB43\xe1\xb0\xd43^f'
59 b'\r<< /Type /XObject /Subtype /Image /Name /im27 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 58 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n,\xa1fjd\x0c\xc8\x19\x103$\xc8\xf8\x84P\xce\x19;\'3\xc6C20\x0c\x10\xcc\x81\x19\x02"\x06eX\xce\x08Y\xcbD"\x19@\xa7'
61 b'\r<< /Type /XObject /Subtype /Image /Name /im28 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 60 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n,\xa51\xd2"\x8c\x8d\x11\x03\x89#5\xb2\x04d\r\x90&E\x08\xf1\x93\x99\xa1\x1e"\x1b \xc6PE\x0c\x89\x19\x1bdi\x95c<!e)'
63 b'\r<< /Type /XObject /Subtype /Image /Name /im29 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 62 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n,\xa9\x08\xa0\xce\xac\x81\x99\x0324\xc8,A\xc4l\xc8\x11\x10(\x822\xa2 F@\xcc\x8d2RE\xc8\x9c\xca\x19\xf3:2\xad\x9e\x19\xad\x94'
65 b'\r<< /Type /XObject /Subtype /Image /Name /im30 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 64 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n 0\xc8\x8d\x0c\xd0\x08>GA\x99\x8c\xd0\x8d\x08\xd0\x8d\xc7\x06Gg\x88\xeagA\x99\x8c\xc4C26)\xb0Cdh3\xe2\x9e\x14\x8a\x19\xd0'
67 b'\r<< /Type /XObject /Subtype /Image /Name /im31 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 66 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n,\xf4\x1974Es\x11\x10\xcfP\x81\x88\xd2\xfd(\xaaX\xac\x11i\x04:-\xa4\xa2eL\x9b\n2g\x9a\xf2)\x94\x96\x94\xca\xc5R\xa8\r'
69 b"\r<< /Type /XObject /Subtype /Image /Name /im32 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 68 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n,\xa0y@\xca\x06t\x19\x06f\x86vB-SS3f\x86u\x8e\xd2\x88\x90324\x14\xc1\x9cd\xe4@\x88\xf9\x19\x846)\xf2'\x19\x1b"
71 b"\r<< /Type /XObject /Subtype /Image /Name /im33 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 70 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n <f2\xd0\xad\x151\xc11\xf0\x7fj@~\xd0\xc7\xf9\x01\xf9S\x82\x07-\x1a\x99^\x92r\xc8S\x91\x02\x95`A\x1d\xa9\xa8j\x99d'"
73 b'\r<< /Type /XObject /Subtype /Image /Name /im34 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 72 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n\xff 5g\x90\x1b\xc6k\x08\x08\x19\xac\xa0\x81\x84\xc2\x06\x108A\xa6\x89\x0e\xc2p\x88\x83\xb4J\xda\x088A\xd1.j\xda\xbc\x9f\xbaO\xbd5'
75 b"\r<< /Type /XObject /Subtype /Image /Name /im35 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 74 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n 1(\x88f|\xc9)\x10\xc8\xd0\xcf\x91\x0f \xa3'#B<2\x88\xf1\x1e\x19F`SF|\xc8du3\xe2\x99\xb2\x143Fle\x06"
77 b'\r<< /Type /XObject /Subtype /Image /Name /im36 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 76 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n\xf2\x03\xec\x88gbY\xdawL\xa44\xd3\x90\x1f^3%wed%\xc8\x0b^wy\\n;\x04A0_\xea@Ma\x04\xca\xb6\n\n'
79 b'\r<< /Type /XObject /Subtype /Image /Name /im37 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 78 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n-2\xb0\xa5T9\xf0\xa4\x80\xa4\xe1\n\x02\x1a\x83\x9d\x03\x9c\nC\x0ex)@S\x81\xca\x02\x1f\x08N\x14\xe0S\xa0S\x81\t\x01\x0b*\xb2('
81 b'\r<< /Type /XObject /Subtype /Image /Name /im38 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 80 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n-R\x93)\xab\nM\xc2\x8e4:\xb5\x1f\xf2\x9b\n\xe5\xb0Y\x95\xd0\x8e\xc0\x91\x90c\x04\xe5\xa7\xa2;K\x82\x0c\x10d\xb4\xc2\x06\x080Yh'
83 b'\r<< /Type /XObject /Subtype /Image /Name /im39 /Filter /CCITTFaxDecode \r/Width 3454 /Height 222 /BitsPerComponent 1 /ColorSpace /DeviceGray \r/Length 82 0 R /DecodeParms << /K -1 /Columns 3454 >> >> \rstream\r\n,\x85,\x99\x19 eP\xc9\x98\xcbuAH\x81\x9d\xd43\xbd\x08\xa9\x19J\x19 \xc8\xd6w\xcc\xaf\x835e9\x90\x99x\x86\xcb\x8ax\xca3'
assistant
I found a useful reference-state simplification: the salt’s sensible heat over the full heating range cancels from the relevant enthalpy difference. The model needs its heat capacity only from 20 to 25 °C to set the reference, then the absolute apparent aqueous heat capacity along the trajectory. I also retrieved Archer’s cited water and dielectric papers; the dielectric PDF is scanned, so its coefficients still need verification from readable pages.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom decimal import Decimal as D\nprint('standard dissolution H at 298.15 K, J/mol:', -D('9040.721')+D('298.15')*(D('115.5108')-D('72.2653')))\nprint('water mass kg:',D('1')*D('1000')*D('.99820675')/D('1000'))\nprint('molality mol/kg:',D('10')/D('58.443')/D('.99820675'))\nPY\""
}
shell output · exit 0
standard dissolution H at 298.15 K, J/mol: 3852.924825
water mass kg: 0.99820675
molality mol/kg: 0.1714142791305302306217939284
shell input
{
  "command": "/usr/bin/bash -lc 'find /harness/.lake -type f -name lean | head -5; ls -la /root/.elan/bin 2>/dev/null; cat /work/evidence/cycle5/local-lean-4.log | head -4'"
}
shell output · exit 0
/work/Model.lean:109:37: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:113:34: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\nimport urllib.request,hashlib,json\nu='https://srd.nist.gov/jpcrdreprint/1.555853.pdf'\np=Path('/work/evidence/cycle7/archer-wang-1990-reprint.pdf')\nb=urllib.request.urlopen(urllib.request.Request(u,headers={'User-Agent':'Mozilla/5.0'}),timeout=35).read();p.write_bytes(b)\nprint(len(b),hashlib.sha256(b).hexdigest(), 'fonts',b.count(b'/Font'))\nPath('/work/evidence/cycle7/reprint-retrieval.json').write_text(json.dumps({'url':u,'bytes':len(b),'sha256':hashlib.sha256(b).hexdigest()},indent=2))\nPY\""
}
shell output · exit 0
3714876 0f00ff409520ffa0415f6488158db7fe745118417e1ec417733b101cac8ec2b2 fonts 260
web_search input
{
  "query": "https://srd.nist.gov/jpcrdreprint/1.555853.pdf",
  "action": {
    "type": "open_page",
    "url": "https://srd.nist.gov/jpcrdreprint/1.555853.pdf"
  }
}
web_search output
{
  "results": [
    {
      "type": "text_result",
      "domain": "srd.nist.gov",
      "ref_id": "turn3view0",
      "snippet": "Total lines: 9129",
      "title": "PšP",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555853.pdf"
    }
  ]
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle5/material-model-evaluation.json; cat /work/evidence/cycle5/evaluate_material_model.py | head -100'"
}
shell output · exit 0
{
  "kind": "calculated empirical model, not measurement or certified error interval",
  "salt_moles": 0.1711068904744794,
  "molality": 0.17141427913053023,
  "v": -0.0004987515884472063,
  "q": -6.589619824872104e-05,
  "dissolution_at_20_J_per_mol": 4746.4593468153325,
  "cooling_energy_at_100_J_per_mol": 821.7165101095526,
  "secant_capacity_change_J_per_mol_K": -49.059285458822245,
  "total_dissolution_at_20_J": 812.1518995971,
  "total_capacity_change_J_per_K": -8.394381783758918,
  "sampled_enthalpy_residuals": [
    {
      "temperature_C": 19.97,
      "cooling_energy_per_mol_J": 4748.452998781568,
      "secant_residual_J_per_mol": 0.5218734024709595
    },
    {
      "temperature_C": 25.0,
      "cooling_energy_per_mol_J": 4416.22266527775,
      "secant_residual_J_per_mol": -84.9402542434713
    },
    {
      "temperature_C": 34.96,
      "cooling_energy_per_mol_J": 3820.7019219073113,
      "secant_residual_J_per_mol": -191.83051444404015
    },
    {
      "temperature_C": 45.0,
      "cooling_energy_per_mol_J": 3348.781109604879,
      "secant_residual_J_per_mol": -171.19610073989716
    },
    {
      "temperature_C": 54.83,
      "cooling_energy_per_mol_J": 2942.3073800386155,
      "secant_residual_J_per_mol": -95.4170542459377
    },
    {
      "temperature_C": 64.86,
      "cooling_energy_per_mol_J": 2484.4645105648096,
      "secant_residual_J_per_mol": -61.19529056775638
    },
    {
      "temperature_C": 75.01,
      "cooling_energy_per_mol_J": 2026.2710808177612,
      "secant_residual_J_per_mol": -21.43697290775911
    },
    {
      "temperature_C": 84.98,
      "cooling_energy_per_mol_J": 1592.3917289068675,
      "secant_residual_J_per_mol": 33.80475120580472
    },
    {
      "temperature_C": 95.18,
      "cooling_energy_per_mol_J": 1063.6508754890876,
      "secant_residual_J_per_mol": 5.468609468011882
    }
  ],
  "limitations": "Concentration interpolation, solid Cp=51 approximation, linear extrapolation of standard dissolution enthalpy from 95.18 to 100 C. Sampled residuals do not certify a uniform bound. Effective affine model continued to 19..101 C. Source response f7c987a52391410bb035542305825b3f; no apparatus observations."
}
"""Arithmetic from supplied literature, NOT a physical experiment.
Uses explicit empirical interpolations/extrapolations described in report.txt.
Standard library only. Decimal arithmetic is for review, Lean checks rationals.
"""
import json
from fractions import Fraction as F
from pathlib import Path
r=lambda x:F(str(x))
n=r(10)/r(58.443)
m=n/r(.99820675)
f=(m-r(.15))/r(.05)
v=(-r(.8329)+f*r(.7802))/1000
q=(-r(60.2)-f*r(13.3))/1000000
rel=lambda t:-(t+r(273.15))**2*(v+2*q*t)
hi20=r(4481)-(r(20)-r(19.97))*657/(25-r(19.97))
hi100=-r(4540)-(r(100)-r(95.18))*1318/(r(95.18)-r(84.98))
h=hi20+rel(r(20))
d100=hi100+51*80+rel(r(100))
s=(d100-h)/80
rows=[]
for t,hi in [('19.97',4481),('25',3824),('34.96',2573),('45',1423),('54.83',335),('64.86',-837),('75.01',-2038),('84.98',-3222),('95.18',-4540)]:
    t=r(t)
    d=hi+51*(t-20)+rel(t)
    fit=h+s*(t-20)
    rows.append(dict(temperature_C=float(t),cooling_energy_per_mol_J=float(d),secant_residual_J_per_mol=float(d-fit)))
result=dict(kind='calculated empirical model, not measurement or certified error interval',salt_moles=float(n),molality=float(m),v=float(v),q=float(q),dissolution_at_20_J_per_mol=float(h),cooling_energy_at_100_J_per_mol=float(d100),secant_capacity_change_J_per_mol_K=float(s),total_dissolution_at_20_J=float(n*h),total_capacity_change_J_per_K=float(n*s),sampled_enthalpy_residuals=rows,limitations='Concentration interpolation, solid Cp=51 approximation, linear extrapolation of standard dissolution enthalpy from 95.18 to 100 C. Sampled residuals do not certify a uniform bound. Effective affine model continued to 19..101 C. Source response f7c987a52391410bb035542305825b3f; no apparatus observations.')
Path('/work/evidence/cycle5/material-model-evaluation.json').write_text(json.dumps(result,indent=2)+'\n')
print(json.dumps(result,indent=2))
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\np=Path('/work/evidence/cycle7')\np.joinpath('revision-notes.txt').write_text('''Cycle 7, 2026-11-18. Work remains in progress; no revised candidate or acceptance.\n\nRead cycle6 revision/request history, cycle5 raw arithmetic and model lineage, the old Model.lean, current host human decisions, check verdict files, and both operator evidence responses. The latest successful real check is checks/0a52ddc3554b4e10b6c5b477fceb0093: proved, with independent extraction/kernel recheck. Earlier extraction-identity and elaboration failures are preserved and were repaired in that attempt. These successes did not address the subsequent human rejection of the material model. No new check is claimed this cycle. The old Model.lean/candidate/report are archived in history/cycle7-start and remain rejected historical files, not a newly submitted physical answer.\n\nIncorporated literature response 8ee08d44180740abb377ff631b6f1452 by reading READING-NOTES.txt, sources.json, PartII source text including equations9-14,20-22,32-38 and references, the supplied solid knots and Parker tables. Visually checked the provided PartII original coefficient and enthalpy/capacity page PNGs. Retain f7c987a52391410bb035542305825b3f and the original observations. No experiments, other agents, paid services, authentication files or prior-run solutions used.\n\nImportant simplification, mathematically derived on paper and NOT yet checked in Lean:\nLet Tr=298.15K, Ts=293.15K, hdis(T,m) be the isothermal integral dissolution enthalpy, and hcr(T) the molar solid enthalpy from the SAME representation. The material difference affecting mixing is d(T)=hdis(T,m)+hcr(T)-hcr(Ts). Kirchhoff gives d'=C_app(T,m), because hdis'=C_app-Cp_cr. Therefore\n d(T)=DeltaH_inf(Tr)+L_phi(Tr,m)+integral(Ts,Tr)Cp_cr(u)du+integral(Tr,T)C_app(u,m)du.\nThis avoids evaluating/integrating the solid spline from20C to every possible mixing temperature. Only its20-to25C increment sets the fixed stored-salt reference. It does not justify constant aqueous capacity or replace the full concentration dependence.\nAtTr, H=G+T*S gives the standard solid dissolution enthalpy, using PartII Table2 and section2:\n DeltaH_inf(Tr)=-9040.721+298.15*(115.5108-72.2653)=3852.924825 J/mol.\nThis is a calculated consequence of the chosen Archer model, not a new measurement or a replacement ofG byH. Do not insert the older JANAF51J/mol/K approximation, Criss-Cobble enthalpy interpolation or Partanen absolute baseline into this model. Table2 quoted anchor uncertainties alone are not a uniform material-error enclosure.\n\nThe fixed scenario remains10g crystallineNaCl stored at20C, ambient20C, pressure0.100MPa, original1L water at20C. The supplied NIST density is treated as an empirical reference value under its stated conditions. Derive mass=(1L)*(1000cm\"'^3/L)*(.99820675g/cm''^3)*(1kg/1000g)=.99820675kg; n=10/58.443mol; m=n/.99820675=.1714142791305302306...mol/kg. Decimal arithmetic used only for diagnostic calculation, not formal certification.\n\nFor variable water+pot enthalpyU and brine+pot enthalpyV, fixed salt enthalpyK, mixingV(z)=U(x)+K and V'\"'>0 give sign(x-z)=sign(V(x)-U(x)-K). The shared Newtonian law N(T)=W-k(T-20) gives N(z)-N(x)=k*(x-z). For positive power, inverse energy balances yield tau'=U'(x)*(1/N(x)-1/N(z)). Hence the timing derivative has the sign ofd(x) whenk>0. Neither mixing cooling nor earliest addition is assumed. Need a source-supported full-curve evaluation (and a formal bound, or clearly labelled empirical enclosure premise supported by reproducible certification) to decide the case. The phase domain must still exclude unsalted boiling before addition and inadmissible mixed states. Constant heater input and common Newtonian loss remain accepted approximations; apparatus parameters remain unknown.\n\nSource dependency audit: ArcherPartII printed798 explicitly requires Hill1990 water EOS and Archer-Wang1990 dielectric model with Bradley-Pitzer DH conventions. Retrieved the original primary references directly from NIST, saving PDFs and SHA256/URLs in source-retrieval.json and reprint-retrieval.json. The first Archer-Wang legacy PDF is scanned; its reprint has searchable text through the web tool. Hill reprint is searchable too. No genuinely unavailable source coefficient has been established. Local pdftotext and scientific Python packages are absent (raw failure recorded by tool output); no libraries were installed. Do NOT represent a tooling inconvenience as absent physical evidence. Web research references: https://srd.nist.gov/jpcrdreprint/1.555853.pdf and https://srd.nist.gov/jpcrdreprint/1.555868.pdf . The literature retrieval closes the previously unprovided-reference gap; numerical reconstruction/validation is still substantial work.\n\nNext request is explicitly a CALCULATION, not another request for the same literature, a physical measurement, a Lean proof or timing recommendation. Ask operator for a reproducible internally consistent Archer EOS implementation and enclosures to be independently inspected/formalized. Need no favorable sign selected, sparse-point linearity, or secant-as-local-capacity assumption. If operator cannot provide a certified enclosure, preserve that limitation and use raw calculations as diagnostics only.\n''')\nq='''Calculation request following evidence response8ee08d44180740abb377ff631b6f1452. Please perform a reproducible thermodynamic-model calculation, using ordinary local/free calculation tools and the supplied primary sources, for the retained10g dry crystallineNaCl initially20C / original1L water20C / ambient20C / pressure0.100MPa scenario. This is not a measurement request, literature-only request, request for another agent, Lean proof, or timing recommendation. No desired sign is stipulated.\n\nThe previously missing source dependencies have now been retrieved: /work/evidence/cycle7/archer-wang-1990-reprint.pdf (https://srd.nist.gov/jpcrdreprint/1.555853.pdf; DOI10.1063/1.555853) and /work/evidence/cycle7/hill-1990.pdf (https://srd.nist.gov/jpcrdreprint/1.555868.pdf; DOI10.1063/1.555868). Retrieval manifests give hashes. Use ArcherPartI/II in /work/inputs/material-literature-002 with Hill water and Archer-Wang dielectric/Debye-Huckel relations to retain the original model conventions. Native local scientific packages/pdf extraction are absent here; the reprints have searchable text via the web, but equations/coefficient signs need original-image verification. All inputs are literature/model choices, not physical measurements.\n\nPlease implement and supply source code, coefficient provenance, units/reference states, diagnostics and raw numerical results for the ABSOLUTE apparent capacityC_app(T,m) and the fixed-stored-solid enthalpy difference d(T)=hdis(T,m)+hcr(T)-hcr(293.15K). Concentration must be calculated, not chosen: water mass=(1L)*(1000cm\"'^3/L)*(.99820675g/cm''^3)*(1kg/1000g)=.99820675kg, n=10/58.443mol, m=n/.99820675kg, approximately .17141427913053mol/kg. Keep the complete composition dependence of Archer equations, not interpolation between table rows.\n\nUseful reference simplification, to be checked independently: Kirchhoff gives d'\"'=C_app (the solid capacity cancels). Thus\n d(T)=[-9040.721+298.15*(115.5108-72.2653)]+L_phi(298.15,m)+integral[293.15,298.15]Cp_cr(u)du+integral[298.15,T]C_app(u,m)du, inJ/mol.\nThe bracket is3852.924825J/mol, derived from DeltaG and the solute-minus-solid entropy; it is not a separate enthalpy datum. L_phi is PartII Eq9; C_app follows Eq21 with Eq38'skJ scale, full interaction terms and pure-water contribution. The solid spline is needed only20-to25C for this reference conversion; do not replace it by a constant51 or splice older JANAF/Partanen/Criss-Cobble baselines. Please verify this reference algebra and report any error rather than building on it.\n\nDesired outputs: evaluations near19,20,25,60,100C, source tabulated coding cross-checks (ArcherPartI Table4; PartII Tables7-10 as relevant), and, if possible, conservative VALIDATED enclosures for d and C_app across19..100C at this fixed concentration and pressure, together with pure-water specificCp bounds and positive brine capacity. Distinguish outward-rounded interval/proven analytic bounds from a grid or finite-difference diagnostic. A script, certificate partition and constituent bounds suitable for later independent Lean verification are particularly useful. If you cannot certify an enclosure, give the implementation and raw diagnostics and explicitly say no uniform bound is certified. Keep empirical model accuracy separate from numerical enclosure error; source confidence intervals are not automatically a global uncertainty band. Do not force d positive if the internally consistent curve changes sign or has a weak margin.\n\nAlso calculate/check feasible liquid-state limits at this composition/pressure using the same phase convention: freezing/solubility, pure-water boiling endpoint, brine boiling endpoint, whether either exceeds100C, and resulting valid temperature range. A solution above pure-water boiling must not be mistaken for stable pure water at thatpressure. Preserve any metastable continuation needed by an apparent-property reference and label it. No heater power, pot capacity or duration needs inventing.\n\nI will derive and formalize the variable-capacity timing comparison myself from U'(T),V'(T)>0, mixing V(z)=U(x)+K, and the already accepted common net-power lawN(T)=W-k*(T-20). Preliminary differentiation yields tau'=U'(x)*(1/N(x)-1/N(z)), so this calculation is needed to determine the actual material regime, not to supply the desired optimum as a premise. Full notes and retained limitations are in /work/evidence/cycle7/revision-notes.txt. No candidate is accepted or newly submitted in this request cycle.'''\np.joinpath('request-question.txt').write_text(q)\nprint('Saved cycle7 source audit, reference derivation, and calculation request.')\nPY\""
}
shell output · exit 0
Saved cycle7 source audit, reference derivation, and calculation request.
assistant
The reference-state derivation is recorded, but I haven’t yet established the full temperature-dependent curve needed for a recommendation. I’m requesting a reproducible calculation of Archer’s consistent model, including feasibility checks and any validated bounds. I’ll stop for the operator’s response; the earlier recommendation remains unaccepted.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\nimport subprocess\nquestion=Path('/work/evidence/cycle7/request-question.txt').read_text()\nr=subprocess.run(['python','/harness/src/vcs_protocol.py','tool','request','--kind','calculation','--question',question],capture_output=True,text=True)\nPath('/work/evidence/cycle7/request-output.txt').write_text(r.stdout+r.stderr)\nprint(r.stdout)\nprint(r.stderr)\nraise SystemExit(r.returncode)\nPY\""
}
shell output · exit 0
{"id": "385ae674960d48e49d45526c2703465f", "kind": "calculation", "question": "Calculation request following evidence response8ee08d44180740abb377ff631b6f1452. Please perform a reproducible thermodynamic-model calculation, using ordinary local/free calculation tools and the supplied primary sources, for the retained10g dry crystallineNaCl initially20C / original1L water20C / ambient20C / pressure0.100MPa scenario. This is not a measurement request, literature-only request, request for another agent, Lean proof, or timing recommendation. No desired sign is stipulated.\n\nThe previously missing source dependencies have now been retrieved: /work/evidence/cycle7/archer-wang-1990-reprint.pdf (https://srd.nist.gov/jpcrdreprint/1.555853.pdf; DOI10.1063/1.555853) and /work/evidence/cycle7/hill-1990.pdf (https://srd.nist.gov/jpcrdreprint/1.555868.pdf; DOI10.1063/1.555868). Retrieval manifests give hashes. Use ArcherPartI/II in /work/inputs/material-literature-002 with Hill water and Archer-Wang dielectric/Debye-Huckel relations to retain the original model conventions. Native local scientific packages/pdf extraction are absent here; the reprints have searchable text via the web, but equations/coefficient signs need original-image verification. All inputs are literature/model choices, not physical measurements.\n\nPlease implement and supply source code, coefficient provenance, units/reference states, diagnostics and raw numerical results for the ABSOLUTE apparent capacityC_app(T,m) and the fixed-stored-solid enthalpy difference d(T)=hdis(T,m)+hcr(T)-hcr(293.15K). Concentration must be calculated, not chosen: water mass=(1L)*(1000cm^3/L)*(.99820675g/cm^3)*(1kg/1000g)=.99820675kg, n=10/58.443mol, m=n/.99820675kg, approximately .17141427913053mol/kg. Keep the complete composition dependence of Archer equations, not interpolation between table rows.\n\nUseful reference simplification, to be checked independently: Kirchhoff gives d'=C_app (the solid capacity cancels). Thus\n d(T)=[-9040.721+298.15*(115.5108-72.2653)]+L_phi(298.15,m)+integral[293.15,298.15]Cp_cr(u)du+integral[298.15,T]C_app(u,m)du, inJ/mol.\nThe bracket is3852.924825J/mol, derived from DeltaG and the solute-minus-solid entropy; it is not a separate enthalpy datum. L_phi is PartII Eq9; C_app follows Eq21 with Eq38'skJ scale, full interaction terms and pure-water contribution. The solid spline is needed only20-to25C for this reference conversion; do not replace it by a constant51 or splice older JANAF/Partanen/Criss-Cobble baselines. Please verify this reference algebra and report any error rather than building on it.\n\nDesired outputs: evaluations near19,20,25,60,100C, source tabulated coding cross-checks (ArcherPartI Table4; PartII Tables7-10 as relevant), and, if possible, conservative VALIDATED enclosures for d and C_app across19..100C at this fixed concentration and pressure, together with pure-water specificCp bounds and positive brine capacity. Distinguish outward-rounded interval/proven analytic bounds from a grid or finite-difference diagnostic. A script, certificate partition and constituent bounds suitable for later independent Lean verification are particularly useful. If you cannot certify an enclosure, give the implementation and raw diagnostics and explicitly say no uniform bound is certified. Keep empirical model accuracy separate from numerical enclosure error; source confidence intervals are not automatically a global uncertainty band. Do not force d positive if the internally consistent curve changes sign or has a weak margin.\n\nAlso calculate/check feasible liquid-state limits at this composition/pressure using the same phase convention: freezing/solubility, pure-water boiling endpoint, brine boiling endpoint, whether either exceeds100C, and resulting valid temperature range. A solution above pure-water boiling must not be mistaken for stable pure water at thatpressure. Preserve any metastable continuation needed by an apparent-property reference and label it. No heater power, pot capacity or duration needs inventing.\n\nI will derive and formalize the variable-capacity timing comparison myself from U'(T),V'(T)>0, mixing V(z)=U(x)+K, and the already accepted common net-power lawN(T)=W-k*(T-20). Preliminary differentiation yields tau'=U'(x)*(1/N(x)-1/N(z)), so this calculation is needed to determine the actual material regime, not to supply the desired optimum as a premise. Full notes and retained limitations are in /work/evidence/cycle7/revision-notes.txt. No candidate is accepted or newly submitted in this request cycle.", "time": "2026-11-18T00:55:51.692975+00:00"}
Stop this cycle. A human must supply the actual response before you resume.


assistant
Requested a reproducible calculation of the temperature-dependent NaCl model and feasible liquid states: `385ae674960d48e49d45526c2703465f`.

Stopped pending the operator’s response. No revised timing recommendation or proof is claimed. Progress and limitations are preserved in [revision notes](/work/evidence/cycle7/revision-notes.txt).

Produced code

checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢
  dsimp only [initialTemperature] at hW ⊢
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/19e916da3a2f417381acb479d8151af9/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
checks/3366e6e934024e17b8832b7253fbd31c/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ 100.1 →
    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧
    (0 < netPower W k 20 x ∧
      netPower W k 20 x <
        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/45e3bdc1f6974c4dae446c78777c9f79/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ (1001 / 10 : ℝ) →
    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧
    (0 < netPower W k 20 x ∧
      netPower W k 20 x <
        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)

Round 8

Messages

user
Requested diagnostic calculation is supplied at /work/inputs/material-calculation-003/. Read DIAGNOSTIC-NOTES.txt first. The implementation uses a declared IAPWS95 water substitution for the unavailable original Hill implementation and corrected Pytzer interaction functions; it is not exact original Archer/Hill reproduction. Raw results, source and hashes are supplied. No interval enclosure, physical measurement or timing answer is supplied. Finite-difference diagnostics must not be reported as certified uniform bounds. Full details:

Requested material calculation: reproducible diagnostic variant

The supplied archer_diagnostic.py and archer-diagnostic-results.json are an operator calculation, not a physical experiment, another scientist's answer, or a formal certificate. They retain the 10 g NaCl / 0.99820675 kg water / 0.100 MPa case and derive molality. No timing conclusion or Lean proof is supplied.

Important model change: no tested implementation of the original Hill1990 water representation was available. This calculation consistently substitutes IAPWS95 water density, enthalpy and heat capacity in the Archer reference formulas and in the Archer-Wang dielectric calculation. It is not exact reproduction of the original Archer/Hill model. Treat it as an explicitly changed empirical representation, and decide whether that representation supports a defensible proof/model. The substitution must remain visible in provenance and cannot be silently identified with the original paper.

The two interaction functions are selected from the retained Pytzer parameter source by AST. Its documented corrections include publication sign/temperature-factor errors and a Rard-letter coefficient. The primary software source is https://github.com/mvdh7/pytzer/blob/main/pytzer/parameters/__init__.py . The source retains its GPLv3 notice. This evidence code is not added to the published harness. Reproduction:
uv run --with iapws==1.5.5 --with scipy==1.18.1 --with mpmath==1.4.1 --with click==8.5.1 python archer_diagnostic.py --out reproduced-results.json
Keep the retained pytzer-parameters.py beside the script; the other two retained Pytzer files are provenance and are hashed by the script. The script reads only two inspected pure functions, not arbitrary module-level code.

Numerical derivative steps 0.1, 0.05, 0.025 K are diagnostic convergence checks. They are not interval arithmetic or outward-rounded bounds. No uniform enclosure of d, C_app, water capacity, brine capacity, phase domain, solubility, or empirical error has been certified. Do not convert extrema of these five temperatures into global assumptions reported as proved bounds.

The raw Table7 comparisons are retained, including discrepancies: at273 K printed beta0 is0.06542 whereas the corrected software gives0.0645233; at323 K printed C1 is0.00639 whereas the corrected software gives0.00637970. Consequently this is not a claim that every table entry agrees to its last digit. Source transcription, corrected representation and original printed tables are distinct objects. Solid Cp from the natural-spline transcription agrees with Table4 at298.15 K to its displayed rounding (50.155875 versus50.16 J/mol/K).

The apparent-property reference uses the high-density liquid-water branch above the pure-water boiling point; at100 C this is metastable reference water at0.100 MPa. Diagnostic phase roots are99.60593 C for pure water and99.76644 C for this brine. No stable pure-water heating path through100 C is asserted. Freezing and solubility limits were not computed. Reprints alone do not turn this numerical phase diagnostic into a formal liquid-domain proof.

You may install ordinary free scientific tools inside the writable /work tree if useful. This supplies the requested calculation to the extent actually achieved, with its model substitution and unresolved numerical certification explicit. Preserve your independence in choosing and proving the scientific model. If a remaining bound is an empirical modeling guard rather than a derived result, identify it plainly and support it; do not assume the timing answer itself.
assistant
I’ll review the retained proofs, check feedback and new calculation, focusing on whether the temperature-dependent material model supports a timing recommendation and which bounds remain unproved.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work'"
}
shell output · exit 0
total 108
drwxrwxr-x  8 1001 1001  4096 Nov 17 23:57 .
drwxr-xr-x  1 root root  4096 Nov 18 02:12 ..
-rw-r--r--  1 1001 1001 21006 Nov 17 23:45 Model.lean
-rw-r--r--  1 1001 1001  4229 Nov 17 23:41 candidate.json
drwxr-xr-x 11 1001 1001  4096 Nov 17 23:45 checks
drwxr-xr-x  2 1001 1001  4096 Nov 17 15:48 diagnostics
drwxr-xr-x  6 1001 1001  4096 Nov 18 00:52 evidence
drwxr-xr-x  8 1001 1001  4096 Nov 18 00:52 history
-rw-------  1 1001 1001  5340 Nov 17 23:57 human-feedback.json
drwxrwxr-x  5 1001 1001  4096 Nov 18 02:11 inputs
-rw-------  1 1001 1001 15186 Nov 17 23:47 last-review-packet.json
-rw-r--r--  1 1001 1001   456 Nov 17 14:15 lean-env.sh
-rw-r--r--  1 1001 1001 14551 Nov 17 23:41 report.txt
drwxr-xr-x  2 1001 1001  4096 Nov 18 02:11 requests
shell input
{
  "command": "/usr/bin/bash -lc 'rg --files /work | head -100'"
}
shell output · exit 0
/usr/bin/bash: line 1: rg: command not found
shell input
{
  "command": "/usr/bin/bash -lc 'find /work/history /work/checks /work/inputs/material-calculation-003 -maxdepth 2 -type f'"
}
shell output · exit 0
/work/history/cycle6-start/report.txt
/work/history/cycle6-start/human-feedback.json
/work/history/cycle6-start/Model.lean
/work/history/cycle6-start/candidate.json
/work/history/cycle5-start/report.txt
/work/history/cycle5-start/Model.lean
/work/history/cycle5-start/candidate.json
/work/history/cycle7-start/report.txt
/work/history/cycle7-start/Model.lean
/work/history/cycle7-start/candidate.json
/work/history/cycle1/report.txt
/work/history/cycle1/human-feedback.json
/work/history/cycle1/Model.lean
/work/history/cycle1/candidate.json
/work/history/cycle2/report.txt
/work/history/cycle2/human-feedback.json
/work/history/cycle2/Model.lean
/work/history/cycle2/candidate.json
/work/history/cycle3/report.txt
/work/history/cycle3/human-feedback.json
/work/history/cycle3/Model.lean
/work/history/cycle3/candidate.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-report.txt
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted-candidate.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/lean.log
/work/checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/extracted.lean
/work/checks/cd3bf32329e547d19d474c1bd79431b9/verdict.json
/work/checks/cd3bf32329e547d19d474c1bd79431b9/Checked.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted-report.txt
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted-candidate.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/lean.log
/work/checks/3366e6e934024e17b8832b7253fbd31c/submitted.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/extracted.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/extracted.lean
/work/checks/3366e6e934024e17b8832b7253fbd31c/verdict.json
/work/checks/3366e6e934024e17b8832b7253fbd31c/Checked.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-report.txt
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted-candidate.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/lean.log
/work/checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/extracted.lean
/work/checks/8ce875bbeedf40f384474d008e4dfa66/verdict.json
/work/checks/8ce875bbeedf40f384474d008e4dfa66/Checked.lean
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-report.txt
/work/checks/19e916da3a2f417381acb479d8151af9/submitted-candidate.json
/work/checks/19e916da3a2f417381acb479d8151af9/lean.log
/work/checks/19e916da3a2f417381acb479d8151af9/submitted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.json
/work/checks/19e916da3a2f417381acb479d8151af9/extracted.lean
/work/checks/19e916da3a2f417381acb479d8151af9/verdict.json
/work/checks/19e916da3a2f417381acb479d8151af9/Checked.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted-report.txt
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted-candidate.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/lean.log
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.lean
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/verdict.json
/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/Checked.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-report.txt
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted-candidate.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/lean.log
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/verdict.json
/work/checks/eb1f4719481a42c1a8b798b0b91aca4d/Checked.lean
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted-report.txt
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted-candidate.json
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/lean.log
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/submitted.lean
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/verdict.json
/work/checks/45e3bdc1f6974c4dae446c78777c9f79/Checked.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-report.txt
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted-candidate.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/lean.log
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/extracted.lean
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/verdict.json
/work/checks/f49ea96bd5de45babf8f3c699ba15e09/Checked.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted-report.txt
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted-candidate.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/lean.log
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/extracted.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/extracted.lean
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/verdict.json
/work/checks/fa26349a1ab0402c9d16ff1354b2240b/Checked.lean
/work/inputs/material-calculation-003/pytzer-constants.py
/work/inputs/material-calculation-003/DIAGNOSTIC-NOTES.txt
/work/inputs/material-calculation-003/archer_diagnostic.py
/work/inputs/material-calculation-003/pytzer-debyehueckel.py
/work/inputs/material-calculation-003/archer-diagnostic-results.json
/work/inputs/material-calculation-003/pytzer-parameters.py
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/inputs/material-calculation-003/DIAGNOSTIC-NOTES.txt /work/evidence/cycle7/revision-notes.txt /work/candidate.json'"
}
shell output · exit 0
Requested material calculation: reproducible diagnostic variant

The supplied archer_diagnostic.py and archer-diagnostic-results.json are an operator calculation, not a physical experiment, another scientist's answer, or a formal certificate. They retain the 10 g NaCl / 0.99820675 kg water / 0.100 MPa case and derive molality. No timing conclusion or Lean proof is supplied.

Important model change: no tested implementation of the original Hill1990 water representation was available. This calculation consistently substitutes IAPWS95 water density, enthalpy and heat capacity in the Archer reference formulas and in the Archer-Wang dielectric calculation. It is not exact reproduction of the original Archer/Hill model. Treat it as an explicitly changed empirical representation, and decide whether that representation supports a defensible proof/model. The substitution must remain visible in provenance and cannot be silently identified with the original paper.

The two interaction functions are selected from the retained Pytzer parameter source by AST. Its documented corrections include publication sign/temperature-factor errors and a Rard-letter coefficient. The primary software source is https://github.com/mvdh7/pytzer/blob/main/pytzer/parameters/__init__.py . The source retains its GPLv3 notice. This evidence code is not added to the published harness. Reproduction:
uv run --with iapws==1.5.5 --with scipy==1.18.1 --with mpmath==1.4.1 --with click==8.5.1 python archer_diagnostic.py --out reproduced-results.json
Keep the retained pytzer-parameters.py beside the script; the other two retained Pytzer files are provenance and are hashed by the script. The script reads only two inspected pure functions, not arbitrary module-level code.

Numerical derivative steps 0.1, 0.05, 0.025 K are diagnostic convergence checks. They are not interval arithmetic or outward-rounded bounds. No uniform enclosure of d, C_app, water capacity, brine capacity, phase domain, solubility, or empirical error has been certified. Do not convert extrema of these five temperatures into global assumptions reported as proved bounds.

The raw Table7 comparisons are retained, including discrepancies: at273 K printed beta0 is0.06542 whereas the corrected software gives0.0645233; at323 K printed C1 is0.00639 whereas the corrected software gives0.00637970. Consequently this is not a claim that every table entry agrees to its last digit. Source transcription, corrected representation and original printed tables are distinct objects. Solid Cp from the natural-spline transcription agrees with Table4 at298.15 K to its displayed rounding (50.155875 versus50.16 J/mol/K).

The apparent-property reference uses the high-density liquid-water branch above the pure-water boiling point; at100 C this is metastable reference water at0.100 MPa. Diagnostic phase roots are99.60593 C for pure water and99.76644 C for this brine. No stable pure-water heating path through100 C is asserted. Freezing and solubility limits were not computed. Reprints alone do not turn this numerical phase diagnostic into a formal liquid-domain proof.

You may install ordinary free scientific tools inside the writable /work tree if useful. This supplies the requested calculation to the extent actually achieved, with its model substitution and unresolved numerical certification explicit. Preserve your independence in choosing and proving the scientific model. If a remaining bound is an empirical modeling guard rather than a derived result, identify it plainly and support it; do not assume the timing answer itself. No acceptance or prescribed optimum is given by this response.
Cycle 7, 2026-11-18. Work remains in progress; no revised candidate or acceptance.

Read cycle6 revision/request history, cycle5 raw arithmetic and model lineage, the old Model.lean, current host human decisions, check verdict files, and both operator evidence responses. The latest successful real check is checks/0a52ddc3554b4e10b6c5b477fceb0093: proved, with independent extraction/kernel recheck. Earlier extraction-identity and elaboration failures are preserved and were repaired in that attempt. These successes did not address the subsequent human rejection of the material model. No new check is claimed this cycle. The old Model.lean/candidate/report are archived in history/cycle7-start and remain rejected historical files, not a newly submitted physical answer.

Incorporated literature response 8ee08d44180740abb377ff631b6f1452 by reading READING-NOTES.txt, sources.json, PartII source text including equations9-14,20-22,32-38 and references, the supplied solid knots and Parker tables. Visually checked the provided PartII original coefficient and enthalpy/capacity page PNGs. Retain f7c987a52391410bb035542305825b3f and the original observations. No experiments, other agents, paid services, authentication files or prior-run solutions used.

Important simplification, mathematically derived on paper and NOT yet checked in Lean:
Let Tr=298.15K, Ts=293.15K, hdis(T,m) be the isothermal integral dissolution enthalpy, and hcr(T) the molar solid enthalpy from the SAME representation. The material difference affecting mixing is d(T)=hdis(T,m)+hcr(T)-hcr(Ts). Kirchhoff gives d'=C_app(T,m), because hdis'=C_app-Cp_cr. Therefore
 d(T)=DeltaH_inf(Tr)+L_phi(Tr,m)+integral(Ts,Tr)Cp_cr(u)du+integral(Tr,T)C_app(u,m)du.
This avoids evaluating/integrating the solid spline from20C to every possible mixing temperature. Only its20-to25C increment sets the fixed stored-salt reference. It does not justify constant aqueous capacity or replace the full concentration dependence.
AtTr, H=G+T*S gives the standard solid dissolution enthalpy, using PartII Table2 and section2:
 DeltaH_inf(Tr)=-9040.721+298.15*(115.5108-72.2653)=3852.924825 J/mol.
This is a calculated consequence of the chosen Archer model, not a new measurement or a replacement ofG byH. Do not insert the older JANAF51J/mol/K approximation, Criss-Cobble enthalpy interpolation or Partanen absolute baseline into this model. Table2 quoted anchor uncertainties alone are not a uniform material-error enclosure.

The fixed scenario remains10g crystallineNaCl stored at20C, ambient20C, pressure0.100MPa, original1L water at20C. The supplied NIST density is treated as an empirical reference value under its stated conditions. Derive mass=(1L)*(1000cm^3/L)*(.99820675g/cm^3)*(1kg/1000g)=.99820675kg; n=10/58.443mol; m=n/.99820675=.1714142791305302306...mol/kg. Decimal arithmetic used only for diagnostic calculation, not formal certification.

For variable water+pot enthalpyU and brine+pot enthalpyV, fixed salt enthalpyK, mixingV(z)=U(x)+K and V'>0 give sign(x-z)=sign(V(x)-U(x)-K). The shared Newtonian law N(T)=W-k(T-20) gives N(z)-N(x)=k*(x-z). For positive power, inverse energy balances yield tau'=U'(x)*(1/N(x)-1/N(z)). Hence the timing derivative has the sign ofd(x) whenk>0. Neither mixing cooling nor earliest addition is assumed. Need a source-supported full-curve evaluation (and a formal bound, or clearly labelled empirical enclosure premise supported by reproducible certification) to decide the case. The phase domain must still exclude unsalted boiling before addition and inadmissible mixed states. Constant heater input and common Newtonian loss remain accepted approximations; apparatus parameters remain unknown.

Source dependency audit: ArcherPartII printed798 explicitly requires Hill1990 water EOS and Archer-Wang1990 dielectric model with Bradley-Pitzer DH conventions. Retrieved the original primary references directly from NIST, saving PDFs and SHA256/URLs in source-retrieval.json and reprint-retrieval.json. The first Archer-Wang legacy PDF is scanned; its reprint has searchable text through the web tool. Hill reprint is searchable too. No genuinely unavailable source coefficient has been established. Local pdftotext and scientific Python packages are absent (raw failure recorded by tool output); no libraries were installed. Do NOT represent a tooling inconvenience as absent physical evidence. Web research references: https://srd.nist.gov/jpcrdreprint/1.555853.pdf and https://srd.nist.gov/jpcrdreprint/1.555868.pdf . The literature retrieval closes the previously unprovided-reference gap; numerical reconstruction/validation is still substantial work.

Next request is explicitly a CALCULATION, not another request for the same literature, a physical measurement, a Lean proof or timing recommendation. Ask operator for a reproducible internally consistent Archer EOS implementation and enclosures to be independently inspected/formalized. Need no favorable sign selected, sparse-point linearity, or secant-as-local-capacity assumption. If operator cannot provide a certified enclosure, preserve that limitation and use raw calculations as diagnostics only.
{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "nacl_immediate_addition_answer"
  },
  "user_facts": [
    "One litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.",
    "Salt will be added; salt quantity, pot, heater and room conditions otherwise unspecified."
  ],
  "model_choices": [
    "Scenario retained from cycle 4: 10 g pure dry crystalline NaCl held at 20 C before addition; ambient and initially equilibrated pot at 20 C; approximately atmospheric pressure. Nominal solvent mass .99820675 kg from NIST 20 C density and molar mass 58.443 g/mol determine .1714143 mol/kg.",
    "Use published Partanen2023 PI(con) relative enthalpy expression, interpolating its v,q between .15 and .20 mol/kg. Standard solid dissolution enthalpy at 20 C is interpolated from actual 19.97 and 25 C entries in its Table 8. Add same-temperature finite-concentration correction; derive H, do not assume its sign.",
    "Effective constant signed solution-minus-water heat capacity S is the 20-to-100 C apparent-enthalpy secant with solid salt referenced to 20 C. Standard dissolution enthalpy at 100 C is linearly extrapolated from 84.98 and 95.18 C values; solid sensible heat uses effective 51 J/(mol K), guided by NIST-JANAF. Derive S from these inputs, not from a preset sign. This affine effective enthalpy model is used on 19..101 C; it is a reduction, not a uniform local-capacity bound. Sampled residuals are disclosed; extrapolation and uniform physical accuracy have no certified uncertainty bound.",
    "Shared constant-input Newtonian heat flow N(T)=W-k*(T-20), k>0, unchanged by salinity. Heating obeys capacity*dT/dt=N(T); constant water+pot capacity C>=3900 J/K. Affine enthalpies, instantaneous adiabatic complete dissolution, no heating interruption, negligible evaporation and material loss; uniform liquid/pot temperature.",
    "Unsalted boiling B0 satisfies 99<=B0<=100.1 C; final brine boiling satisfies B0<=B<=101 C. Assume enough power W>k*(B-20). Compare all additions 20<=x<=B0, allowing only the onset of unsalted boiling without dwelling. Liquid/solubility applicability is explicit. The proof derives positive final capacity, postmix temperature>=19 C, postmix temperature<=x<=B, and positive heat flow."
  ],
  "sources": [
    "Operator source bundle /work/inputs/material-evidence-001/sources.json, with original PDFs/text and SHA256 hashes; response f7c987a52391410bb035542305825b3f.",
    "https://doi.org/10.1007/s10953-023-01322-y \u2014 Partanen2023 Eqs.13-19 and Tables 2,8; Table 8 attributes standard solid dissolution data to Criss and Cobble.",
    "https://doi.org/10.1007/s10953-024-01412-5 \u2014 Partanen2025 Eqs.9-10,18 and discussion of competing absolute heat-capacity baselines.",
    "https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf \u2014 GLP10 water density.",
    "https://janaf.nist.gov/tables/Cl-055.html \u2014 crystalline NaCl heat capacity.",
    "https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2 \u2014 molar mass and solid correlation validity limits.",
    "https://iapws.org/technical-guidance/release/IAPWS-95 \u2014 pure-water thermal and phase relationships."
  ],
  "incorporated_inputs": [
    "f7c987a52391410bb035542305825b3f"
  ],
  "proof_scope": "For the explicit literature-calibrated effective affine-enthalpy NaCl case, derives signed capacity/dissolution bounds, positive final capacity, feasible liquid mixing temperatures, net-power increase from energy conservation and the shared loss law, and immediate addition as a global minimizer over 20 C through onset of unsalted boiling. Retains signed-capacity and reference-consistent balance derivations, stage-time uniqueness from inverse energy balance, and full-schedule derivative/monotonicity proof. No sorry or additional axiom. Conditional on exposed empirical interpolation/extrapolation, effective constant-capacity reduction, phase and apparatus premises; does not certify their physical accuracy, infer a numerical duration, resolve all unspecified salts/apparatus, or claim human approval. Raw calculations and Lean diagnostics preserved in evidence/cycle5/."
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/inputs/material-calculation-003/archer-diagnostic-results.json'"
}
shell output · exit 0
{
  "diagnostic_only": true,
  "uniform_bound_certified": false,
  "empirical_accuracy_certified": false,
  "model": "Corrected Archer interactions from retained Pytzer source, AW90 dielectric algorithm with IAPWS95 water density and water thermodynamics replacing Hill1990 throughout. No claim of exact original Archer/Hill reproduction.",
  "typo_corrections": "Pytzer A92ii_eq36 and bC_Na_Cl_A92ii include explicitly documented publication typo/Rard-letter corrections; retained source is the authority for this diagnostic variant.",
  "units": "K,MPa,J,mol,kg; source Eq38 kJ converted toJ",
  "water_mass_kg": 0.99820675,
  "salt_moles": 0.1711068904744794,
  "molality_mol_kg": 0.17141427913053023,
  "anchor_Hinf_J_mol": 3852.924825000002,
  "solid_20to25_increment_J_mol": 250.48376105180054,
  "evaluations": [
    {
      "temperature_C": 19,
      "water": {
        "rho": 998.4076683695472,
        "h_J_kg": 79821.63882894396,
        "s_J_kgK": 282.16473590548804,
        "cp_J_kgK": 4184.786566441226
      },
      "solid_cp_J_molK": 50.012995919237014,
      "Aphi": 0.3875512724582349,
      "step_diagnostics": [
        {
          "finite_difference_step_K": 0.1,
          "Capp_J_molK": -82.60841732702482,
          "d_J_mol": 4933.413403244298
        },
        {
          "finite_difference_step_K": 0.05,
          "Capp_J_molK": -82.60841017159319,
          "d_J_mol": 4933.413403351538
        },
        {
          "finite_difference_step_K": 0.025,
          "Capp_J_molK": -82.60845096917342,
          "d_J_mol": 4933.413403392078
        }
      ]
    },
    {
      "temperature_C": 20,
      "water": {
        "rho": 998.206543497657,
        "h_J_kg": 84006.05394280252,
        "s_J_kgK": 296.4631107343622,
        "cp_J_kgK": 4184.055067055111
      },
      "solid_cp_J_molK": 50.03712000772833,
      "Aphi": 0.3881891051041579,
      "step_diagnostics": [
        {
          "finite_difference_step_K": 0.1,
          "Capp_J_molK": -80.2508468362696,
          "d_J_mol": 4851.993846636298
        },
        {
          "finite_difference_step_K": 0.05,
          "Capp_J_molK": -80.25085363429002,
          "d_J_mol": 4851.993846664618
        },
        {
          "finite_difference_step_K": 0.025,
          "Capp_J_molK": -80.25086888607956,
          "d_J_mol": 4851.993846520205
        }
      ]
    },
    {
      "temperature_C": 25,
      "water": {
        "rho": 997.0470390177073,
        "h_J_kg": 104918.8928278232,
        "s_J_kgK": 367.1999840219454,
        "cp_J_kgK": 4181.318830957995
      },
      "solid_cp_J_molK": 50.155875194481766,
      "Aphi": 0.3914704340847887,
      "step_diagnostics": [
        {
          "finite_difference_step_K": 0.1,
          "Capp_J_molK": -70.11799336348344,
          "d_J_mol": 4477.154526775705
        },
        {
          "finite_difference_step_K": 0.05,
          "Capp_J_molK": -70.11798937067283,
          "d_J_mol": 4477.154526744171
        },
        {
          "finite_difference_step_K": 0.025,
          "Capp_J_molK": -70.11801480255247,
          "d_J_mol": 4477.154526759524
        }
      ]
    },
    {
      "temperature_C": 60,
      "water": {
        "rho": 983.1952445303456,
        "h_J_kg": 251247.58080367217,
        "s_J_kgK": 831.2505002919979,
        "cp_J_kgK": 4184.956223318834
      },
      "solid_cp_J_molK": 50.915906525992185,
      "Aphi": 0.4189127029866592,
      "step_diagnostics": [
        {
          "finite_difference_step_K": 0.1,
          "Capp_J_molK": -43.56510292151271,
          "d_J_mol": 2650.757533359435
        },
        {
          "finite_difference_step_K": 0.05,
          "Capp_J_molK": -43.56510428815018,
          "d_J_mol": 2650.7575333680497
        },
        {
          "finite_difference_step_K": 0.025,
          "Capp_J_molK": -43.565134004776894,
          "d_J_mol": 2650.7575331566845
        }
      ]
    },
    {
      "temperature_C": 100,
      "water": {
        "rho": 958.3483854219735,
        "h_J_kg": 419165.0977021002,
        "s_J_kgK": 1307.2122527835138,
        "cp_J_kgK": 4215.6768904884375
      },
      "solid_cp_J_molK": 51.68497772616351,
      "Aphi": 0.4599045116004594,
      "step_diagnostics": [
        {
          "finite_difference_step_K": 0.1,
          "Capp_J_molK": -53.788432415617066,
          "d_J_mol": 790.2965039625042
        },
        {
          "finite_difference_step_K": 0.05,
          "Capp_J_molK": -53.788435937334704,
          "d_J_mol": 790.2965039686369
        },
        {
          "finite_difference_step_K": 0.025,
          "Capp_J_molK": -53.78842701749308,
          "d_J_mol": 790.2965038625885
        }
      ]
    }
  ],
  "table7_parameter_checks": [
    {
      "temperature_K": 273,
      "Archer_table7": [
        0.06542,
        0.2265,
        0.001304,
        -0.06719
      ],
      "corrected_Pytzer_parameters": [
        0.06452331100763073,
        0.22653155696855976,
        0.0013045478300113497,
        -0.06719534701067756
      ]
    },
    {
      "temperature_K": 298,
      "Archer_table7": [
        0.08055,
        0.263,
        0.0002682,
        -0.01022
      ],
      "corrected_Pytzer_parameters": [
        0.08055438081123406,
        0.26295774358914115,
        0.0002680967029236728,
        -0.010225398609230338
      ]
    },
    {
      "temperature_K": 323,
      "Archer_table7": [
        0.09139,
        0.2826,
        -0.0005856,
        0.00639
      ],
      "corrected_Pytzer_parameters": [
        0.09139450696245291,
        0.28257853941434147,
        -0.0005857485373611008,
        0.006379700926860478
      ]
    },
    {
      "temperature_K": 373,
      "Archer_table7": [
        0.1008,
        0.3218,
        -0.001725,
        0.01267
      ],
      "corrected_Pytzer_parameters": [
        0.10079233985022225,
        0.32174937409865445,
        -0.0017249463378924287,
        0.012667596670541036
      ]
    }
  ],
  "phase_diagnostics": {
    "water_boil_C": 99.60592889712336,
    "brine_boil_C": 99.76643566762726,
    "method": "IAPWS95 vapor/liquid chemical potentials + corrected-Archer osmotic activity with IAPWS95-based AW90; not original Hill representation; no rigorous enclosure",
    "freezing_and_solubility": "not implemented; no certified phase interval supplied"
  },
  "dependencies": {
    "iapws": "1.5.5",
    "numpy": "2.5.5",
    "scipy": "1.18.1",
    "mpmath": "1.4.1",
    "click": "8.5.1"
  },
  "source_hashes": {
    "archer_diagnostic.py": "f80c33c86e2e3e56ed330784e8ed2aa1a7163808ea49e7cf371574b24c272a6d",
    "pytzer-parameters.py": "12a9eead97b13968efa753b05a23f51584bb5d99ab98a70287372755cd6ebeb5",
    "pytzer-debyehueckel.py": "49d3d310d0e0d6a4f6a1eed3b8062268b13f3c87a9e9fe13351e4dd80a68d294",
    "pytzer-constants.py": "84b4029d5deb2c6d51b9be6ed6784f43a7b96594bc167d7a497e8708eec4f078"
  }
}
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '1,260p' /work/inputs/material-calculation-003/archer_diagnostic.py\""
}
shell output · exit 0
"""Reproducible material-property diagnostics; IAPWS95 water substitution, NOT Hill.

No rigorous interval certificate, experiment, or timing recommendation is produced.
Pytzer interaction functions below are loaded from retained inspected source; its
GNU GPLv3 notice remains in that file. Dependencies: click, scipy, mpmath, iapws.
"""
import ast
from functools import lru_cache
import hashlib
import importlib.metadata
import json
import math
from pathlib import Path

import click
import mpmath as mp
from scipy.interpolate import CubicSpline
from scipy.integrate import quad
from scipy.optimize import brentq
from iapws import IAPWS95

ROOT = Path(__file__).resolve().parent
mp.mp.dps = 45
RG = 8.31451
MR = 6.0
P_MPA = 0.1
TR = 298.15
TS = 293.15
NACL = 10 / 58.443
MWATER = .99820675
M = NACL / MWATER
WATER = IAPWS95()


def retained_functions(filename, names):
    source = (ROOT / filename).read_text()
    module = ast.parse(source)
    selected = [n for n in module.body if isinstance(n, ast.FunctionDef) and n.name in names]
    assert {n.name for n in selected} == set(names)
    namespace = {}
    exec(compile(ast.Module(selected, []), filename, 'exec'), namespace)
    return namespace


PARAMS = retained_functions('pytzer-parameters.py', ['A92ii_eq36', 'bC_Na_Cl_A92ii'])


@lru_cache(maxsize=20000)
def liquid(T):
    """Keep the high-density water branch even above its saturation temperature."""
    rho = brentq(lambda r: WATER._Helmholtz(r, T)['P'] - P_MPA * 1000,
                 900., 1100., xtol=1e-10)
    v = WATER._Helmholtz(rho, T)
    delta, tau = rho / WATER.rhoc, WATER.Tc / T
    p0 = WATER._phi0(tau, delta)
    pr = WATER._phir(tau, delta)
    cv = -WATER.R * tau**2 * (p0['fiott'] + pr['firtt'])
    cp = cv + WATER.R * (1 + delta*pr['fird'] - delta*tau*pr['firdt'])**2 / (
        1 + 2*delta*pr['fird'] + delta**2*pr['firdd'])
    return {'rho': rho, 'h_J_kg': float(v['h'])*1000,
            's_J_kgK': float(v['s'])*1000, 'cp_J_kgK': float(cp)*1000}


def aphi(T):
    """AW90 dielectric/DH algorithm, with IAPWS95 density instead of Hill."""
    rho = liquid(float(T))['rho'] / 1000
    p = P_MPA
    b = [-.04044525, 103.6180, 75.32165, -23.23778, -3.548184,
         -1246.311, 263307.7, -.6928953, -204.4473]
    gm = (b[0]*p/T + b[1]/math.sqrt(T) + b[2]/(T-215)
          + b[3]/math.sqrt(T-215) + b[4]/(T-215)**.25
          + math.exp(b[5]/T+b[6]/T**2+b[7]*p/T+b[8]*p/T**2))
    g = gm*rho+1
    aa = (1.444e-24 + g*(1.84e-18)**2/(3*1.380658e-16*T)) * 4*math.pi*6.0221367e23*rho/(3*18.0153)
    dielectric = (1+9*aa+3*math.sqrt(9*aa*aa+2*aa+1))/4
    return math.sqrt(2e-3*math.pi*rho*6.0221367e23) * (
        100*(1.6021773e-19)**2/(4*math.pi*dielectric*8.8541878e-12*1.380658e-23*T))**1.5/3


def aphi_derivatives(T, step):
    x0, xm, xp = aphi(T), aphi(T-step), aphi(T+step)
    xmm, xpp = aphi(T-2*step), aphi(T+2*step)
    return ((xmm-8*xm+8*xp-xpp)/(12*step),
            (-xpp+16*xp-30*x0+16*xm-xmm)/(12*step**2))


@lru_cache(maxsize=10000)
def bc(T):
    vals = PARAMS['bC_Na_Cl_A92ii'](mp.mpf(T), 10)
    return tuple(vals[i] for i in [0, 1, 3, 4])


def factors(m):
    x, y = 2*math.sqrt(m), 2.5*math.sqrt(m)
    return (2*(1-(1+x)*math.exp(-x))/x**2,
            4*(6-(6+6*y+3*y*y+y**3)*math.exp(-y))/y**4)


def interaction_derivatives(T, m):
    gb, gc = factors(m)
    first = [float(mp.diff(lambda u: bc(u)[i], mp.mpf(T))) for i in range(4)]
    second = [float(mp.diff(lambda u: bc(u)[i], mp.mpf(T), 2)) for i in range(4)]
    bt, ct = first[0]+gb*first[1], first[2]+gc*first[3]
    btt, ctt = second[0]+gb*second[1], second[2]+gc*second[3]
    return bt, ct, btt+2*bt/T, ctt+2*ct/T


def lphi(T, m=M, step=.05):
    da, _ = aphi_derivatives(T, step)
    bt, ct, _, _ = interaction_derivatives(T, m)
    return (4*RG*T*T*da*math.log1p(1.2*math.sqrt(m))/1.2
            - 2*RG*T*T*(m*bt+m*m*ct))


def cp_ref(T):
    return 1000*(1.62690371649145-.767143070769565*T/300
                 + .211473310430416*(T/300)**2-1.00267947284134*100/T)


def h_ref_primitive(T):
    return 1000*(1.62690371649145*T-.767143070769565*T*T/600
                 + .211473310430416*T**3/270000-1.00267947284134*100*math.log(T))


def capp(T, m=M, step=.05):
    da, daa = aphi_derivatives(T, step)
    ac = 4*RG*(2*T*da+T*T*daa)
    _, _, bm, cm = interaction_derivatives(T, m)
    _, _, br, cr = interaction_derivatives(T, MR)
    return (cp_ref(T)-liquid(T)['cp_J_kgK']/MR
            + ac/1.2*math.log((1+1.2*math.sqrt(m))/(1+1.2*math.sqrt(MR)))
            - 2*RG*T*T*(m*bm-MR*br+m*m*cm-MR*MR*cr))


KNOTS = [0,5,7.5,15,20,45,90,220,400,550,800,1100]
KVALUES = [20.4174,18.6946,18.2037,15.2827,13.2900,8.12535,5.77101,
           5.62745,7.04825,7.41175,5.08930,-8.76890]
SPLINE = CubicSpline(KNOTS, KVALUES, bc_type='natural')


def cp_cr(T):
    return float((T/(SPLINE(T)+.25*T))**3)


SOLID_INCREMENT = quad(cp_cr, TS, TR, epsabs=1e-9)[0]
HINF = -9040.721+TR*(115.5108-72.2653)


def stored_solid_difference(T, m=M, step=.05):
    dh = (h_ref_primitive(T)-h_ref_primitive(TR)
          - (liquid(T)['h_J_kg']-liquid(TR)['h_J_kg'])/MR
          + lphi(T,m,step)-lphi(T,MR,step)-lphi(TR,m,step)+lphi(TR,MR,step))
    return HINF+lphi(TR,m,step)+SOLID_INCREMENT+dh


def osmotic(T,m=M):
    b0,b1,c0,c1=map(float,bc(T))
    return (1-aphi(T)*math.sqrt(m)/(1+1.2*math.sqrt(m))
            +m*(b0+b1*math.exp(-2*math.sqrt(m)))
            +2*m*m*(c0+c1*math.exp(-2.5*math.sqrt(m))))


def phase_difference(T,m):
    liq=liquid(T)
    rv=brentq(lambda r:WATER._Helmholtz(r,T)['P']-P_MPA*1000,.3,1.5)
    vap=WATER._Helmholtz(rv,T)
    gdiff=(float(vap['h'])*1000-T*float(vap['s'])*1000
           -liq['h_J_kg']+T*liq['s_J_kgK'])
    logaw=-2*.0180153*m*osmotic(T,m) if m else 0.
    return gdiff-WATER.R*1000*T*logaw


@click.command()
@click.option('--out',type=click.Path(path_type=Path),required=True)
def main(out):
    rows=[]
    for celsius in [19,20,25,60,100]:
        T=celsius+273.15
        row={'temperature_C':celsius,'water':liquid(T),'solid_cp_J_molK':cp_cr(T),'Aphi':aphi(T)}
        row['step_diagnostics']=[{'finite_difference_step_K':h,'Capp_J_molK':capp(T,step=h),'d_J_mol':stored_solid_difference(T,step=h)} for h in [.1,.05,.025]]
        rows.append(row)
        click.echo(json.dumps(row),err=True)
    coding=[]
    for T,expected in [(273,[.06542,.2265,.001304,-.06719]),(298,[.08055,.2630,.0002682,-.01022]),(323,[.09139,.2826,-.0005856,.00639]),(373,[.1008,.3218,-.001725,.01267])]:
        coding.append({'temperature_K':T,'Archer_table7':expected,'corrected_Pytzer_parameters':list(map(float,bc(T)))})
    phases={'water_boil_C':brentq(lambda T:phase_difference(T,0),368,378)-273.15,
            'brine_boil_C':brentq(lambda T:phase_difference(T,M),368,378)-273.15,
            'method':'IAPWS95 vapor/liquid chemical potentials + corrected-Archer osmotic activity with IAPWS95-based AW90; not original Hill representation; no rigorous enclosure',
            'freezing_and_solubility':'not implemented; no certified phase interval supplied'}
    result={'diagnostic_only':True,'uniform_bound_certified':False,'empirical_accuracy_certified':False,
            'model':'Corrected Archer interactions from retained Pytzer source, AW90 dielectric algorithm with IAPWS95 water density and water thermodynamics replacing Hill1990 throughout. No claim of exact original Archer/Hill reproduction.',
            'typo_corrections':'Pytzer A92ii_eq36 and bC_Na_Cl_A92ii include explicitly documented publication typo/Rard-letter corrections; retained source is the authority for this diagnostic variant.',
            'units':'K,MPa,J,mol,kg; source Eq38 kJ converted toJ',
            'water_mass_kg':MWATER,'salt_moles':NACL,'molality_mol_kg':M,'anchor_Hinf_J_mol':HINF,'solid_20to25_increment_J_mol':SOLID_INCREMENT,
            'evaluations':rows,'table7_parameter_checks':coding,'phase_diagnostics':phases,
            'dependencies':{name:importlib.metadata.version(name) for name in ['iapws','numpy','scipy','mpmath','click']},
            'source_hashes':{n:hashlib.sha256((ROOT/n).read_bytes()).hexdigest() for n in ['archer_diagnostic.py','pytzer-parameters.py','pytzer-debyehueckel.py','pytzer-constants.py']}}
    out.write_text(json.dumps(result,indent=2)+'\n')
    click.echo(str(out))


if __name__=='__main__':
    main()
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/0a52ddc3554b4e10b6c5b477fceb0093/verdict.json /work/checks/3366e6e934024e17b8832b7253fbd31c/verdict.json; cat /work/lean-env.sh'"
}
shell output · exit 0
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T23:45:21.072186+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean",
    "conclusions": [
      "nacl_immediate_addition_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "nacl_immediate_addition_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime",
      "naclRelativeEnthalpy",
      "naclDissolutionAt20",
      "naclCapacityChange"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "nacl_immediate_addition_answer": {
        "original_sha256": "5a458dff2d8b618009ca0d3584944b20e164a2f1014b272491283e0cc96533b7",
        "extracted_sha256": "5a458dff2d8b618009ca0d3584944b20e164a2f1014b272491283e0cc96533b7"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "naclCapacityChange": true,
      "naclRelativeEnthalpy._proof_1": true,
      "naclCapacityChange._proof_1": true,
      "naclCapacityChange._proof_2": true,
      "naclCapacityChange._proof_3": true,
      "naclCapacityChange._proof_4": true,
      "naclRelativeEnthalpy": true,
      "naclRelativeEnthalpy._proof_2": true,
      "naclRelativeEnthalpy._proof_3": true,
      "naclRelativeEnthalpy._proof_4": true,
      "naclDissolutionAt20": true,
      "naclDissolutionAt20._proof_1": true,
      "naclDissolutionAt20._proof_2": true,
      "naclDissolutionAt20._proof_3": true,
      "naclCapacityChange._proof_5": true,
      "mixedTemperature": true,
      "netPower": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "naclCapacityChange": {
        "original_sha256": "8670a93d0602bcf463a61fee28b4b0132903fa86b5e02063d783a457e0e20d95",
        "extracted_sha256": "8670a93d0602bcf463a61fee28b4b0132903fa86b5e02063d783a457e0e20d95"
      },
      "naclRelativeEnthalpy._proof_1": {
        "original_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e",
        "extracted_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e"
      },
      "naclCapacityChange._proof_1": {
        "original_sha256": "eeb571f066f9fd41079c19239c0556ae7d3640be2b5a3e6c76d862f948944a3d",
        "extracted_sha256": "eeb571f066f9fd41079c19239c0556ae7d3640be2b5a3e6c76d862f948944a3d"
      },
      "naclCapacityChange._proof_2": {
        "original_sha256": "7bb889d46cc76bcb2cc9e5e670df469595a74df8cf7126322071ab7c0be53472",
        "extracted_sha256": "7bb889d46cc76bcb2cc9e5e670df469595a74df8cf7126322071ab7c0be53472"
      },
      "naclCapacityChange._proof_3": {
        "original_sha256": "2ba7335cd3609ac74f89befa6e2bece6c16a746f1305f1fad2a3147c66ccbd9e",
        "extracted_sha256": "2ba7335cd3609ac74f89befa6e2bece6c16a746f1305f1fad2a3147c66ccbd9e"
      },
      "naclCapacityChange._proof_4": {
        "original_sha256": "95a4b8dc8de5704474a04eac7090e59fc6f0dc381b86621ea7b579a8aa989d48",
        "extracted_sha256": "95a4b8dc8de5704474a04eac7090e59fc6f0dc381b86621ea7b579a8aa989d48"
      },
      "naclRelativeEnthalpy": {
        "original_sha256": "241e6415aa135e0478293cafa7224aa561f642e34d34ff566230d5a0769af57e",
        "extracted_sha256": "241e6415aa135e0478293cafa7224aa561f642e34d34ff566230d5a0769af57e"
      },
      "naclRelativeEnthalpy._proof_2": {
        "original_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8",
        "extracted_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8"
      },
      "naclRelativeEnthalpy._proof_3": {
        "original_sha256": "39fafd58592e6f7d4b38f634565fbb6e9bbefe69aeeb93ddf7f184e06209bc4d",
        "extracted_sha256": "39fafd58592e6f7d4b38f634565fbb6e9bbefe69aeeb93ddf7f184e06209bc4d"
      },
      "naclRelativeEnthalpy._proof_4": {
        "original_sha256": "d2b35f180040d865daeefeff1cb2ec8fe91bba9d4feab29fa08cb1cfa9f06a13",
        "extracted_sha256": "d2b35f180040d865daeefeff1cb2ec8fe91bba9d4feab29fa08cb1cfa9f06a13"
      },
      "naclDissolutionAt20": {
        "original_sha256": "707be014e24f264bc42917b6e4b5fd07e07e1ddcc652e798ef1322c03c11d740",
        "extracted_sha256": "707be014e24f264bc42917b6e4b5fd07e07e1ddcc652e798ef1322c03c11d740"
      },
      "naclDissolutionAt20._proof_1": {
        "original_sha256": "d26507b0493f14007ca36940f4f486d4f8a4042b7d1750e0d82a0fc7cd37e327",
        "extracted_sha256": "d26507b0493f14007ca36940f4f486d4f8a4042b7d1750e0d82a0fc7cd37e327"
      },
      "naclDissolutionAt20._proof_2": {
        "original_sha256": "f5c712256be2eb371af21a0efe29a66a19279c2854a6d5728c3b1c27261e70b9",
        "extracted_sha256": "f5c712256be2eb371af21a0efe29a66a19279c2854a6d5728c3b1c27261e70b9"
      },
      "naclDissolutionAt20._proof_3": {
        "original_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae",
        "extracted_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae"
      },
      "naclCapacityChange._proof_5": {
        "original_sha256": "6a4d87025b5494d28bb170c00a0004de722e9ecc9d872d9068b023a8a066c4f0",
        "extracted_sha256": "6a4d87025b5494d28bb170c00a0004de722e9ecc9d872d9068b023a8a066c4f0"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "nacl_immediate_addition_answer": "\u2200 (C W k B0 B x : \u211d), \u21913900 \u2264 C \u2192 0 < k \u2192 \u219199 \u2264 B0 \u2192 B0 \u2264 \u21911001 / \u219110 \u2192 B0 \u2264 B \u2192 B \u2264 \u2191101 \u2192 k * (B - initialTemperature) < W \u2192 x \u2208 Set.Icc initialTemperature B0 \u2192 0 < C + naclCapacityChange \u2227 (\u219119 \u2264 mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x \u2227 mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x \u2264 x) \u2227 (0 < netPower W k initialTemperature x \u2227 netPower W k initialTemperature x < netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) \u2227 boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature \u2264 boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x"
    },
    "extracted_file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:41:59.788687+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
export LEAN_PATH=/harness/.lake/packages/plausible/.lake/build/lib/lean:/harness/.lake/packages/proofwidgets/.lake/build/lib/lean:/harness/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/harness/.lake/packages/mathlib/.lake/build/lib/lean:/harness/.lake/packages/aesop/.lake/build/lib/lean:/harness/.lake/packages/batteries/.lake/build/lib/lean:/harness/.lake/packages/importGraph/.lake/build/lib/lean:/harness/.lake/packages/Qq/.lake/build/lib/lean
assistant
The new calculation gives positive dissolution-energy differences at the five sampled temperatures, but it explicitly certifies no bound between them. It also substitutes IAPWS95 water properties for Hill’s model. I’ll keep those limits visible and replace the rejected constant-capacity proof with a variable-capacity argument. The remaining material check is a bound over the full feasible temperature range.
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '1,220p' /work/Model.lean\""
}
shell output · exit 0
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
shell input
{
  "command": "/usr/bin/bash -lc 'ls /harness/.lake/packages/mathlib/Mathlib/Analysis/Calculus; command -v lean; command -v python; command -v uv; find /work/evidence/cycle5 -maxdepth 1 -type f'"
}
shell output · exit 0
ls: cannot access '/harness/.lake/packages/mathlib/Mathlib/Analysis/Calculus': No such file or directory
/usr/local/bin/python
/work/evidence/cycle5/check-3.txt
/work/evidence/cycle5/check-4.txt
/work/evidence/cycle5/material-model-calculation.log
/work/evidence/cycle5/local-lean-2.log
/work/evidence/cycle5/local-lean-1.log
/work/evidence/cycle5/local-lean-3.log
/work/evidence/cycle5/trace_extraction.py
/work/evidence/cycle5/local-lean-4.log
/work/evidence/cycle5/extracted-conclusion-repr.txt
/work/evidence/cycle5/trace-extracted.json
/work/evidence/cycle5/extract-trace-1.txt
/work/evidence/cycle5/trace-extraction-result.txt
/work/evidence/cycle5/trace-extracted.lean
/work/evidence/cycle5/evaluate_material_model.py
/work/evidence/cycle5/check-1.txt
/work/evidence/cycle5/extract-trace-2.txt
/work/evidence/cycle5/original-conclusion-repr.txt
/work/evidence/cycle5/check-2.txt
/work/evidence/cycle5/material-model-evaluation.json
/work/evidence/cycle5/revision-trace.txt
shell input
{
  "command": "/usr/bin/bash -lc 'find /work/inputs/material-literature-002 -maxdepth 2 -type f; find /work/inputs/material-evidence-001 -maxdepth 1 -type f'"
}
shell output · exit 0
/work/inputs/material-literature-002/READING-NOTES.txt
/work/inputs/material-literature-002/archer-1992-part1-crystalline.txt
/work/inputs/material-literature-002/parker-table-X.png
/work/inputs/material-literature-002/part2-temperature-functions.png
/work/inputs/material-literature-002/archer-solid-knots.csv
/work/inputs/material-literature-002/parker-heat-capacity.png
/work/inputs/material-literature-002/parker-enthalpy-infinity.png
/work/inputs/material-literature-002/parker-relative-enthalpy-25C.csv
/work/inputs/material-literature-002/sources.json
/work/inputs/material-literature-002/parker-apparent-heat-capacity.csv
/work/inputs/material-literature-002/archer-1992-part2-solution.txt
/work/inputs/material-literature-002/parker-1965-nsrds2.txt
/work/inputs/material-literature-002/archer-1992-part1-crystalline.pdf
/work/inputs/material-literature-002/part2-coefficients.png
/work/inputs/material-literature-002/parker-1965-nsrds2.pdf
/work/inputs/material-literature-002/archer-1992-part2-solution.pdf
/work/inputs/material-literature-002/part2-enthalpy-capacity.png
/work/inputs/material-literature-002/part2-definitions.png
/work/inputs/material-literature-002/part1-eqs.png
/work/inputs/material-literature-002/part1-knots.png
/work/inputs/material-evidence-001/archer-preview-01.png
/work/inputs/material-evidence-001/archer-1992-nacl-water.pdf
/work/inputs/material-evidence-001/water-density-evaluation.json
/work/inputs/material-evidence-001/nist-webbook-nacl.html
/work/inputs/material-evidence-001/sources.json
/work/inputs/material-evidence-001/partanen-2023-enthalpy.pdf
/work/inputs/material-evidence-001/nist-webbook-nacl.txt
/work/inputs/material-evidence-001/nist-water-density.pdf
/work/inputs/material-evidence-001/iapws95-2018.pdf
/work/inputs/material-evidence-001/iapws95-2018.txt
/work/inputs/material-evidence-001/archer-1992-nacl-water.txt
/work/inputs/material-evidence-001/nist-janaf-nacl-solid.html
/work/inputs/material-evidence-001/nist-water-density.txt
/work/inputs/material-evidence-001/partanen-2025-heat-capacity.txt
/work/inputs/material-evidence-001/archer-preview-02.png
/work/inputs/material-evidence-001/partanen-2025-heat-capacity.pdf
/work/inputs/material-evidence-001/partanen-2023-enthalpy.txt
/work/inputs/material-evidence-001/archer-1992-nacl-water-ocr.txt
/work/inputs/material-evidence-001/nist-janaf-nacl-solid.txt
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport json\nfrom pathlib import Path\np=Path('/work/checks')\nfor d in sorted(p.iterdir()):\n f=d/'verdict.json'\n if f.exists():\n  x=json.loads(f.read_text());print(d.name,x.get('verdict'),x.get('error',''),x.get('time'))\nPY\""
}
shell output · exit 0
0a52ddc3554b4e10b6c5b477fceb0093 proved  2026-11-17T23:45:21.072186+00:00
19e916da3a2f417381acb479d8151af9 proved  2026-11-17T14:22:00.296935+00:00
3366e6e934024e17b8832b7253fbd31c not_proved independent extraction failed 2026-11-17T23:41:59.788687+00:00
45e3bdc1f6974c4dae446c78777c9f79 not_proved Lean, kernel recheck or axiom audit failed; see lean.log 2026-11-17T23:44:19.408976+00:00
8ce875bbeedf40f384474d008e4dfa66 proved  2026-11-17T15:48:51.378080+00:00
cd3bf32329e547d19d474c1bd79431b9 proved  2026-11-16T18:27:31.048579+00:00
eb1f4719481a42c1a8b798b0b91aca4d not_proved Lean, kernel recheck or axiom audit failed; see lean.log 2026-11-16T18:25:46.169042+00:00
f49ea96bd5de45babf8f3c699ba15e09 not_proved independent extraction failed 2026-11-16T18:26:03.961421+00:00
fa26349a1ab0402c9d16ff1354b2240b not_proved independent extraction failed 2026-11-17T23:42:43.075074+00:00
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\np=Path('/work/inputs/material-literature-002/archer-1992-part2-solution.txt')\ns=p.read_text()\nfor q in ['38)', 'Hill', '6 mol', '9040', '115.5108']:\n start=s.find(q);print(q, s[max(0,start-350):start+850])\nPY\""
}
shell output · exit 0
https://doi.org/10.1063/1.555913

https://doi.org/10.1063/1.555915
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/45e3bdc1f6974c4dae446c78777c9f79/lean.log | tail -45; cat /work/checks/fa26349a1ab0402c9d16ff1354b2240b/verdict.json | head -20'"
}
shell output · exit 0
                  (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero k (Nat.rawCast 1)
                    (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero B0 (Nat.rawCast 1)
                      (Mathlib.Meta.NormNum.IsInt.to_isNat
                        (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                          (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                          (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                          (Eq.refl (Int.ofNat 0))))))
                  (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0))))
            (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))))
        (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
          (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le (Mathlib.Tactic.Linarith.sub_neg_of_lt hpowB)
            (Mathlib.Tactic.Linarith.sub_nonpos_of_le a))
          (Mathlib.Tactic.Linarith.sub_nonpos_of_le
            (mul_nonneg_of_nonpos_of_nonpos (le_of_lt (Mathlib.Tactic.Linarith.sub_neg_of_lt hk))
              (Mathlib.Tactic.Linarith.sub_nonpos_of_le
                hB))))))) (hdomain : initialTemperature ≤
  B0 := sorry) (hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤
  B := le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl B0⟩))
  hB) (feasible : (initialTemperature ≤ x ∧ x ≤ B0) ∧
  (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ B) ∧
    0 < netPower W k 20 x ∧
      0 <
        netPower W k 20
          (mixedTemperature C naclCapacityChange naclDissolutionAt20 20
            x) := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20 19 B0 initialTemperature B0 x
  hc0 hc hk
  (Eq.mpr (id (congrArg (fun _a => 19 ≤ _a) hi))
    (Mathlib.Meta.NormNum.isNat_le_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 19))
      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 20)) (Eq.refl true)))
  (le_refl initialTemperature) hdomain (le_refl B0) hz19 hzB hpow0 hpowB
  hx) (hj : netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x =
  k * (naclCapacityChange * (x - 20) + naclDissolutionAt20) /
    (C +
      naclCapacityChange) := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x
  (ne_of_gt
    hc)) (hjpos : 0 <
  netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) -
    netPower W k 20
      x := Eq.mpr (id (congrArg (fun _a => 0 < _a) hj))
  (div_pos (mul_pos hk (hcool x hx))
    hc)) ⊢ netPower W k initialTemperature x <
  netPower W k initialTemperature
    (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x) VAS_END
VAS_LISTED
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-17T23:42:43.075074+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
shell input
{
  "command": "/usr/bin/bash -lc 'mkdir -p /work/history/cycle8-start /work/evidence/cycle8\ncp /work/Model.lean /work/candidate.json /work/report.txt /work/history/cycle8-start/'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\np=Path('/work/evidence/cycle8/revision-notes.txt')\np.write_text('''Cycle 8: review and analytical reduction; NOT a new candidate or acceptance.\n\nRead the current host human decisions and all three supplied response records. Read material-calculation-003 DIAGNOSTIC-NOTES.txt, its full archer_diagnostic.py and raw JSON. Read cycle7 revision notes, the historical Model.lean and candidate, primary PartII searchable equations/reference sections, and previous actual check verdicts. Latest checked historical proof was 0a52ddc3554b4e10b6c5b477fceb0093: proved; subsequent human rejection remains binding. Extraction failures and elaboration failures remain preserved in /work/checks; the latest historical pass repaired them, but did not repair the scientific approximation. No new Lean check or material certificate is claimed this cycle. Archived the unchanged historical public files in history/cycle8-start.\n\nNew evidence incorporated for analysis: response 385ae674960d48e49d45526c2703465f. It is a diagnostic variant, not original Archer/Hill: consistent IAPWS95 substitution, corrected Pytzer interactions. It reports no uniform numerical or empirical bound. At 19,20,25,60,100 C, respectively, its step=.05 enthalpy differences d are 4933.4134,4851.9938,4477.1545,2650.7575,790.2965 J/mol. These are samples only. Cp_app samples are negative. Neither fact establishes a uniform-temperature sign. Derivative-step agreement is no truncation/roundoff certificate. Phase roots 99.60593 and99.76644 C are also diagnostics, not certified liquid domains. No freezing/solubility calculation was supplied. No measurements or other agents used.\n\nModel lineage: the effective secant capacity, interpolated Partanen concentration correction, extrapolated Criss-Cobble enthalpy and constant solid capacity of the old candidate remain rejected. Do not reuse them. Current development uses full temperature-dependent enthalpies. The new IAPWS-substituted representation is a proposed explicit empirical model change only; its numerical enclosure would not validate its empirical accuracy or identify it with original Archer/Hill. Keep full m dependence and fixed 20C stored-solid reference.\n\nAnalytical reduction for a future proof, not yet a Lean theorem:\nU(T)=water+pot enthalpy; V(T)=brine+pot enthalpy; K=enthalpy of stored solid at20C. Define D(T)=V(T)-U(T)-K=n*d(T). U',V'>0 on the applicable liquid intervals. Instantaneous adiabatic mixing is V(z(x))=U(x)+K. Strict increase of V implies z(x)<=x iff D(x)>=0. It also implies z increases with x. With common net power N(T)=W-k*(T-20), N(z)-N(x)=k*(x-z); this derives the after/before relationship and does not presume cooling or the sign of Cp_app.\n\nLet F'(T)=U'(T)/N(T), G'(T)=V'(T)/N(T) be the inverse first-law time primitives, not fitted times. Tau(x)=F(x)-F(20)+G(B)-G(z(x)). Differentiating the mixing balance gives V'(z)*z'=U'(x). Hence tau'=U'(x)*(1/N(x)-1/N(z)). On positive-power paths with k>=0 and D>=0 this is nonnegative. With k=0 the derivative vanishes regardless of D. With k>0, its sign is sign(D). This argument permits either sign and arbitrary temperature variation of V'-U'; no constant-capacity reduction is needed. A global minimum at20C requires a bound on D across the entire admissible addition-temperature interval, not merely its sign at20C or at samples.\n\nA derivative-free time comparison is also possible in energy coordinates: salt and water follow different inverse enthalpy temperatures at the SAME total energy. Earlier addition replaces a pure-water segment by a brine segment. If D>=0 and V is increasing, the brine temperature at the same energy is lower, N is larger, and the reciprocal power integrated over that segment is smaller. This gives the same criterion without differentiating the mixing inverse. It still requires a uniform material bound and feasible states, and is not a way to omit them.\n\nFurther cancellation, independently derived from the diagnostic code/reference identities:\nLet Tr=298.15 K, Ts=293.15 K, mr=6 mol/kg, A(T)=h_ref_primitive(T), L(T,m)=L_phi(T,m), hw(T)=pure-water specific enthalpy J/kg, Icr=integral(Ts,Tr)Cp_cr.\nd(T)=Hinf+Icr+A(T)-A(Tr)-(hw(T)-hw(Tr))/6 +L(T,m)-L(T,6)+L(Tr,6).\nHere Hinf=Gdiss(Tr)+Tr*(Ssolute(Tr)-Ssolid(Tr))=3852.924825 J/mol. L(Tr,m) cancels. This form needs no quadrature of aqueous capacity, no high-temperature solid enthalpy, and no interpolated/extrapolated standard dissolution table. An interval evaluation of this direct formula only needs density/enthalpy and first density derivative for L; capacity bounds additionally need second density derivatives (analytic/automatic differentiation rather than finite differences). Numerical d bounds should be computed by interval partition with rigorously enclosed implicit water roots, derivative formulas, exp/log/powers, reference constants and the small solid integral. Grid extrema alone remain insufficient.\n\nNeeded material certificate is now focused: evaluate this declared representation at the derived composition, obtain actual enclosures for d(T) over20..100C, and coarse bounds on water Cp and Cp_app over19..100C. A certificate may report inconclusive sign. Finite sample extrema must not become assumptions claimed as proved. Empirical model validity is separate, remains reviewable even after exact arithmetic certification, and no original-Hill equivalence is asserted.\n\nFeasibility reduction once material bounds exist: U'=mass*Cpwater+Cp_pot; V'=U'+n*Cp_app, with Cp_pot>=0. Bounds on components derive positive U',V'; do not assume C>=3900. A cooling bound D<=dmax*n and a positive lower V' imply x-z<=D/Vmin, keeping the initial mixed state above19C if D(20)<Vmin*1K. Monotonic z then gives z(x)>=z(20). If D>=0, z(x)<=x<=B0<=B. Heating may end at pure-water boiling onset but may not wait through it. All initial water, mixed brine and final trajectories must lie in their respective phase domains. Apparat us remains unspecified: positive input/loss coefficient, enough input to maintain N>0 up to B, shared Newtonian loss, nonnegative pot capacity, and no material loss. No duration can be inferred from original information.\n\nNext action is a targeted calculation request for certified enclosures of the direct formula and component capacities, preserving failure/inconclusive output. No new candidate is submitted, and historical candidate.json remains archived/rejected rather than endorsed. Formalization and real harness check must follow receipt of a suitable certificate; no unconditional timing recommendation or human approval is claimed.\n'''.replace('Apparat us','Apparatus'))\nprint(p)\nPY\""
}
shell output · exit 0
/work/evidence/cycle8/revision-notes.txt
assistant
The variable-capacity derivation gives a clear criterion: under the shared heat-loss law, delaying salt increases the total boiling time wherever adding it causes a temperature drop. Heat-capacity changes can have either sign.

I also reduced the material calculation to a direct enthalpy formula, avoiding the rejected secant approximation. I’ll request certified bounds for that formula; the five sampled values alone cannot establish the timing recommendation.
shell input
{
  "command": "/usr/bin/bash -lc \"python /harness/src/vcs_protocol.py tool request --kind calculation --question 'Follow-up to response 385ae674960d48e49d45526c2703465f: I read the supplied code, raw diagnostics and limitations. They do not certify a full-temperature sign, and I will not treat derivative-step convergence or five sample extrema as a bound. Cycle8 analytical reductions and provenance are saved in /work/evidence/cycle8/revision-notes.txt. No new candidate is submitted or accepted.\n\nPlease supply a reproducible VALIDATED NUMERICAL enclosure calculation, or an explicit failure certificate, for the retained 10g NaCl / original1L water20C / stored solid20C / ambient20C / pressure0.100MPa scenario. No measurement, other agent, Lean proof or timing recommendation is requested. Use ordinary free/local tools only. Retain the full derived composition m=(10/58.443)/(.99820675). I explicitly distinguish the new corrected-Archer/Pytzer + AW90 + IAPWS95 variant from original Archer/Hill; its empirical validity remains a separate exposed model choice, not something interval arithmetic establishes. Please do not silently introduce another representation or parameter tuning.\n\nThe key calculation can be narrower than the previous full request. An independently derived cancellation of your implementation gives, with Tr=298.15K, Ts=293.15K, mr=6mol/kg:\n d(T)=Hinf+Icr+A(T)-A(Tr)-(hw(T)-hw(Tr))/6 +Lphi(T,m)-Lphi(T,6)+Lphi(Tr,6).\nA is your h_ref_primitive, hw the liquid-reference water enthalpy inJ/kg, Icr=integral(Ts,Tr)Cp_cr from the retained natural spline, and Hinf=-9040.721+Tr*(115.5108-72.2653). Lphi(Tr,m) cancels; this avoids aqueous quadrature and high-temperature solid enthalpy. Please independently verify the reduction and all references/units before using it. d has the fixed stored-solid20C reference, not isothermal same-temperature reactants.\n\nRequested deliverable: implement analytic or automatic derivatives of the declared model rather than finite differences, and rigorously enclose d(T) on20..100C. Also obtain sufficiently coarse certified bounds for pure-water specificCp and absolute Cp_app on19..100C to derive positive total capacities from component storage and a nonnegative pot capacity. Report actual enclosures, including inconclusive or sign-changing results; no desired sign is stipulated. In the direct d formula, Lphi needs first density derivatives; capacity needs higher derivatives. Enclose the implicit IAPWS liquid-density root and its derivative denominators. Keep any metastable pure-water reference above its boiling point labelled separately from an admissible pure-water path. Outward-rounded interval arithmetic, validated Taylor methods or explicit analytic derivative/error bounds with rational margins are suitable. A denser grid, finite-difference step agreement or nonvalidated optimizer is not a certificate.\n\nPlease supply code, exact constants/provenance, interval partition and constituent bounds with failure/roundoff/truncation handling, so the inequalities can subsequently be independently verified and connected to the Lean proof. If rigorous numerical certification cannot be performed, identify the exact unresolved operation and retain its failure rather than returning another sample-only result as a bound. Separately state what empirical accuracy is and is not supported for this changed representation; do not assert physical uncertainty from numerical enclosure width.\n\nIf feasible, certify coarse brackets for the two boiling roots and provide a supported liquid/complete-dissolution domain for approximately0.1714mol/kg brine from19C to its boiling point. If phase certification remains unavailable, identify that remaining independent physical input precisely. No heater power, pot mass, heating duration or time saving should be invented.\n\nReason these bounds matter: for variable enthalpies U,V, mixing V(z)=U(x)+K and D=V-U-K=n*d imply z<=x iff D>=0 when V increases. The accepted common loss law gives N(z)-N(x)=k*(x-z); inverse energy balances yield tau prime=U prime(x)*(1/N(x)-1/N(z)). This is our own timing derivation, not a requested answer. Uniform bounds decide its regime while permitting negative, varying solution-minus-water capacity. The comparison excludes waiting through unsalted boiling and inadmissible phase states. Your response will be evidence, not human acceptance.'\""
}
shell output · exit 0
{"id": "e619fbb0992b47fab14c4641bd0dcbf2", "kind": "calculation", "question": "Follow-up to response 385ae674960d48e49d45526c2703465f: I read the supplied code, raw diagnostics and limitations. They do not certify a full-temperature sign, and I will not treat derivative-step convergence or five sample extrema as a bound. Cycle8 analytical reductions and provenance are saved in /work/evidence/cycle8/revision-notes.txt. No new candidate is submitted or accepted.\n\nPlease supply a reproducible VALIDATED NUMERICAL enclosure calculation, or an explicit failure certificate, for the retained 10g NaCl / original1L water20C / stored solid20C / ambient20C / pressure0.100MPa scenario. No measurement, other agent, Lean proof or timing recommendation is requested. Use ordinary free/local tools only. Retain the full derived composition m=(10/58.443)/(.99820675). I explicitly distinguish the new corrected-Archer/Pytzer + AW90 + IAPWS95 variant from original Archer/Hill; its empirical validity remains a separate exposed model choice, not something interval arithmetic establishes. Please do not silently introduce another representation or parameter tuning.\n\nThe key calculation can be narrower than the previous full request. An independently derived cancellation of your implementation gives, with Tr=298.15K, Ts=293.15K, mr=6mol/kg:\n d(T)=Hinf+Icr+A(T)-A(Tr)-(hw(T)-hw(Tr))/6 +Lphi(T,m)-Lphi(T,6)+Lphi(Tr,6).\nA is your h_ref_primitive, hw the liquid-reference water enthalpy inJ/kg, Icr=integral(Ts,Tr)Cp_cr from the retained natural spline, and Hinf=-9040.721+Tr*(115.5108-72.2653). Lphi(Tr,m) cancels; this avoids aqueous quadrature and high-temperature solid enthalpy. Please independently verify the reduction and all references/units before using it. d has the fixed stored-solid20C reference, not isothermal same-temperature reactants.\n\nRequested deliverable: implement analytic or automatic derivatives of the declared model rather than finite differences, and rigorously enclose d(T) on20..100C. Also obtain sufficiently coarse certified bounds for pure-water specificCp and absolute Cp_app on19..100C to derive positive total capacities from component storage and a nonnegative pot capacity. Report actual enclosures, including inconclusive or sign-changing results; no desired sign is stipulated. In the direct d formula, Lphi needs first density derivatives; capacity needs higher derivatives. Enclose the implicit IAPWS liquid-density root and its derivative denominators. Keep any metastable pure-water reference above its boiling point labelled separately from an admissible pure-water path. Outward-rounded interval arithmetic, validated Taylor methods or explicit analytic derivative/error bounds with rational margins are suitable. A denser grid, finite-difference step agreement or nonvalidated optimizer is not a certificate.\n\nPlease supply code, exact constants/provenance, interval partition and constituent bounds with failure/roundoff/truncation handling, so the inequalities can subsequently be independently verified and connected to the Lean proof. If rigorous numerical certification cannot be performed, identify the exact unresolved operation and retain its failure rather than returning another sample-only result as a bound. Separately state what empirical accuracy is and is not supported for this changed representation; do not assert physical uncertainty from numerical enclosure width.\n\nIf feasible, certify coarse brackets for the two boiling roots and provide a supported liquid/complete-dissolution domain for approximately0.1714mol/kg brine from19C to its boiling point. If phase certification remains unavailable, identify that remaining independent physical input precisely. No heater power, pot mass, heating duration or time saving should be invented.\n\nReason these bounds matter: for variable enthalpies U,V, mixing V(z)=U(x)+K and D=V-U-K=n*d imply z<=x iff D>=0 when V increases. The accepted common loss law gives N(z)-N(x)=k*(x-z); inverse energy balances yield tau prime=U prime(x)*(1/N(x)-1/N(z)). This is our own timing derivation, not a requested answer. Uniform bounds decide its regime while permitting negative, varying solution-minus-water capacity. The comparison excludes waiting through unsalted boiling and inadmissible phase states. Your response will be evidence, not human acceptance.", "time": "2026-11-18T02:15:55.114893+00:00"}
Stop this cycle. A human must supply the actual response before you resume.
assistant
Requested validated bounds for the temperature-dependent enthalpy model (request `e619fbb0992b47fab14c4641bd0dcbf2`). The supplied sample calculations do not establish a timing optimum.

Derivation and limitations are preserved in [revision notes](/work/evidence/cycle8/revision-notes.txt). No new candidate or successful check is claimed. Awaiting the operator’s response.

Produced code

checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢
  dsimp only [initialTemperature] at hW ⊢
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/19e916da3a2f417381acb479d8151af9/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S the additional capacity, Ts salt temperature, H dissolution
   energy absorbed. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The initial cooling and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- Derive the mixing balance rather than assuming a cooling amount. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- Positive net power up to B, cool salt, and nonnegative dissolution cost
   imply cooling on mixing, hence an increase of net power at that instant.
   The heat-transfer coefficient itself has NOT been increased by salt. -/
lemma power_order :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    0 < netPower W k A x ∧
    netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hcool : 0 ≤ S * (x - Ts) + H :=
    add_nonneg (mul_nonneg hS (by linarith)) hH
  have hjump := power_change C S H Ts W k A x (ne_of_gt hc)
  have hnonneg : 0 ≤ k * (S * (x - Ts) + H) / (C + S) :=
    div_nonneg (mul_nonneg (le_of_lt hk) hcool) (le_of_lt hc)
  have hp : 0 < netPower W k A x := by
    unfold netPower at *
    nlinarith
  exact ⟨hp, by linarith⟩

/- Scientific answer: in this explicit Newton-loss model immediate
   addition (20 C, elapsed time zero) is a global weak minimum over
   admissible later additions. Also expose the derived power jump. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A x : ℝ),
    0 < C → 0 ≤ S → 0 ≤ H → Ts ≤ initialTemperature →
    0 < k → 0 < netPower W k A B →
    initialTemperature ≤ x → x ≤ B →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (netPower W k A x ≤ netPower W k A (mixedTemperature C S H Ts x)) ∧
    (boilingTime C S H Ts B W k A initialTemperature ≤
      boilingTime C S H Ts B W k A x) ∧
    (heatingTime C W k A initialTemperature initialTemperature = 0) := by
  intro C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  have hc : 0 < C + S := by linarith
  have hord := power_order C S H Ts B W k A x hC hS hH hTs hk hB hix hxB
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), hord.2, ?_, ?_⟩
  · have hd : ∀ y ∈ Set.Icc initialTemperature B,
        HasDerivAt (boilingTime C S H Ts B W k A)
          (C / netPower W k A y -
           C / netPower W k A (mixedTemperature C S H Ts y)) y := by
      intro y hy
      have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hy.1 hy.2
      exact boiling_time_derivative C S H Ts B W k A y (ne_of_gt hc)
        (ne_of_gt hk) (ne_of_gt ho.1) (ne_of_gt (lt_of_lt_of_le ho.1 ho.2))
    have hm : MonotoneOn (boilingTime C S H Ts B W k A)
        (Set.Icc initialTemperature B) := by
      apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
      · intro y hy
        exact (hd y hy).continuousAt.continuousWithinAt
      · intro y hy
        exact (hd y (interior_subset hy)).hasDerivWithinAt
      · intro y hy
        have hmem := interior_subset hy
        have ho := power_order C S H Ts B W k A y hC hS hH hTs hk hB hmem.1 hmem.2
        have hz : 0 < netPower W k A (mixedTemperature C S H Ts y) :=
          lt_of_lt_of_le ho.1 ho.2
        have he : C / netPower W k A (mixedTemperature C S H Ts y) ≤
            C / netPower W k A y := by
          apply (div_le_div_iff₀ hz ho.1).2
          exact mul_le_mul_of_nonneg_left ho.2 (le_of_lt hC)
        linarith
    exact hm ⟨le_refl _, le_trans hix hxB⟩ ⟨hix, hxB⟩ hix
  · unfold heatingTime
    rw [sub_self, mul_zero]
checks/3366e6e934024e17b8832b7253fbd31c/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ 100.1 →
    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧
    (0 < netPower W k 20 x ∧
      netPower W k 20 x <
        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/45e3bdc1f6974c4dae446c78777c9f79/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/8ce875bbeedf40f384474d008e4dfa66/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
checks/cd3bf32329e547d19d474c1bd79431b9/submitted.lean
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied initial water temperature, in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  initialTemperature ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - initialTemperature) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - initialTemperature) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * initialTemperature - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/eb1f4719481a42c1a8b798b0b91aca4d/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/f49ea96bd5de45babf8f3c699ba15e09/submitted.lean
import Mathlib.Data.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- A schedule: water temperature x just before salt addition (deg C),
   elapsed addition time a (s), mixed temperature z (deg C), and first
   arrival at the final solution boiling temperature at time t (s). -/
structure HeatingRun where
  x : ℝ
  a : ℝ
  z : ℝ
  t : ℝ

/- C is water plus pot heat capacity, S the added salt's effective heat
   capacity (J/K), H the dissolution heat cost (J, positive for endothermic),
   Ts the salt's initial temperature, B the final boiling temperature.
   P and Q are constant NET heating powers before and after addition (W).
   The three equalities express heating, instantaneous mixing/dissolution,
   and subsequent heating, respectively. No evaporation or phase change
   occurs before the endpoint; that is an applicability assumption.
   The inequalities ensure forward times and heating to the endpoint. -/
def HeatBalance (C S H Ts B P Q : ℝ) (r : HeatingRun) : Prop :=
  20 ≤ r.x ∧ 0 ≤ r.a ∧ r.a ≤ r.t ∧ r.z ≤ B ∧
  P * r.a = C * (r.x - 20) ∧
  (C + S) * r.z = C * r.x + S * Ts - H ∧
  Q * (r.t - r.a) = (C + S) * (B - r.z)

/- Eliminate the unobserved mixing temperature and addition time from
   energy conservation; this is derived, not an assumed timing formula. -/
lemma time_from_balance :
    ∀ (C S H Ts B P Q : ℝ) (r : HeatingRun),
    0 < P → 0 < Q → HeatBalance C S H Ts B P Q r →
    r.t = C * (r.x - 20) / P +
      ((C + S) * B - C * r.x - S * Ts + H) / Q := by
  intro C S H Ts B P Q r hP hQ hr
  rcases hr with ⟨_, _, _, _, hpre, hmix, hpost⟩
  have he : Q * r.t = Q * r.a + (C + S) * B - C * r.x - S * Ts + H := by
    nlinarith [hmix, hpost]
  field_simp [ne_of_gt hP, ne_of_gt hQ]
  nlinarith [congrArg (fun v : ℝ => P * v) he,
    congrArg (fun v : ℝ => Q * v) hpre]

/- Scientific conclusion: for two admissible addition temperatures x<y,
   later addition takes longer exactly when the salted stage heats faster;
   it takes less time exactly when that stage heats slower. Equal powers
   give equal completion times and the stated common energy/power time.
   All parameters are left symbolic: the observations do not fit them. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B P Q : ℝ) (r s : HeatingRun),
    0 < C → 0 ≤ S → 0 < P → 0 < Q →
    HeatBalance C S H Ts B P Q r →
    HeatBalance C S H Ts B P Q s → r.x < s.x →
    (r.t < s.t ↔ P < Q) ∧
    (s.t < r.t ↔ Q < P) ∧
    (s.t = r.t ↔ Q = P) ∧
    (Q = P → r.t = ((C + S) * B - C * 20 - S * Ts + H) / P) := by
  intro C S H Ts B P Q r s hC hS hP hQ hr hs hxy
  have hd : 0 < C * (s.x - r.x) := mul_pos hC (sub_pos.mpr hxy)
  have hpq : 0 < P * Q := mul_pos hP hQ
  have hid : P * Q * (s.t - r.t) = C * (s.x - r.x) * (Q - P) := by
    rw [time_from_balance C S H Ts B P Q s hP hQ hs,
      time_from_balance C S H Ts B P Q r hP hQ hr]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
  have hforward : (0 < s.t - r.t ↔ 0 < Q - P) := by
    calc
      0 < s.t - r.t ↔ 0 < P * Q * (s.t - r.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (Q - P) := by rw [hid]
      _ ↔ 0 < Q - P := mul_pos_iff_of_pos_left hd
  have hrev : P * Q * (r.t - s.t) = C * (s.x - r.x) * (P - Q) := by
    nlinarith [hid]
  have hback : (0 < r.t - s.t ↔ 0 < P - Q) := by
    calc
      0 < r.t - s.t ↔ 0 < P * Q * (r.t - s.t) :=
        (mul_pos_iff_of_pos_left hpq).symm
      _ ↔ 0 < C * (s.x - r.x) * (P - Q) := by rw [hrev]
      _ ↔ 0 < P - Q := mul_pos_iff_of_pos_left hd
  refine ⟨sub_pos.symm.trans (hforward.trans sub_pos),
    sub_pos.symm.trans (hback.trans sub_pos), ?_, ?_⟩
  · constructor
    · intro ht
      have hz : C * (s.x - r.x) * (Q - P) = 0 := by
        rw [← hid, ht]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hd) hz)
      · linarith
    · intro heq
      have hz : P * Q * (s.t - r.t) = 0 := by
        rw [hid, heq]
        ring
      rcases mul_eq_zero.mp hz with hz | hz
      · exact False.elim ((ne_of_gt hpq) hz)
      · linarith
  · intro heq
    rw [time_from_balance C S H Ts B P Q r hP hQ hr, heq]
    field_simp [ne_of_gt hP, ne_of_gt hQ]
    <;> ring
checks/fa26349a1ab0402c9d16ff1354b2240b/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    3900 ≤ C → 0 < k → 99 ≤ B0 → B0 ≤ (1001 / 10 : ℝ) →
    B0 ≤ B → B ≤ 101 → k * (B - 20) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x ≤ x) ∧
    (0 < netPower W k 20 x ∧
      netPower W k 20 x <
        netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 20 B W k 20 x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)

Round 9

Messages

user
The requested rigorous numerical certificate was not produced. See /work/inputs/material-calculation-004/interval-certification-status.json for the exact unresolved operations. This is a retained unsuccessful calculation, not a proof that certification is impossible. The supplied diagnostic code has no interval enclosure of the implicit water-density root/derivatives, no validated finite-difference error, no validated quadrature or phase/solubility domain. No new grid is supplied as a bound. Your direct d(T) cancellation is algebraically consistent with the retained implementation and its stored-solid reference. No uniform sign or global Cp bound is certified by this response.

Operator clarification under the user's delegation to finish the remaining cycles: this is an illustrative scientific-model proof task. A fully validated implementation of every imported empirical EOS is not required as an additional project. You may choose a tractable, explicitly declared empirical material representation, derive its parameters from the supplied calorimetric literature rather than assuming a timing answer, and prove the material/capacity and timing implications in Lean. The accepted scientific target includes heat-capacity changes due to salt and a connection to a reasonable real material regime. Do not assume the requested optimum, or report sample extrema as uniform proofs. Keep any empirical family, validity-domain and physical guard clearly exposed. If a representation cannot be justified/closed, state the concrete limitation and supply the useful conditional result rather than repeatedly requesting the same unimplemented numerical infrastructure. A change of representation would be explicit and reviewable, never a silent substitution. All previous primary literature remains available. no heater power, time saving, pot mass or physical measurement is invented.
assistant
I’ll review the retained proof and diagnostics, then build a tractable material model with explicit limitations and check the revised timing result in Lean.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work'"
}
shell output · exit 0
total 108
drwxrwxr-x  8 1001 1001  4096 Nov 17 23:57 .
drwxr-xr-x  1 root root  4096 Nov 18 02:18 ..
-rw-r--r--  1 1001 1001 21006 Nov 17 23:45 Model.lean
-rw-r--r--  1 1001 1001  4229 Nov 17 23:41 candidate.json
drwxr-xr-x 11 1001 1001  4096 Nov 17 23:45 checks
drwxr-xr-x  2 1001 1001  4096 Nov 17 15:48 diagnostics
drwxr-xr-x  7 1001 1001  4096 Nov 18 02:15 evidence
drwxr-xr-x  9 1001 1001  4096 Nov 18 02:15 history
-rw-------  1 1001 1001  5340 Nov 17 23:57 human-feedback.json
drwxrwxr-x  6 1001 1001  4096 Nov 18 02:18 inputs
-rw-------  1 1001 1001 15186 Nov 17 23:47 last-review-packet.json
-rw-r--r--  1 1001 1001   456 Nov 17 14:15 lean-env.sh
-rw-r--r--  1 1001 1001 14551 Nov 17 23:41 report.txt
drwxr-xr-x  2 1001 1001  4096 Nov 18 02:18 requests
shell input
{
  "command": "/usr/bin/bash -lc \"find /work -maxdepth 3 -type f -name '*notes*' -o -name '*feedback*' -o -name 'Model.lean' -o -name 'candidate.json'\""
}
shell output · exit 0
/work/human-feedback.json
/work/Model.lean
/work/history/cycle6-start/human-feedback.json
/work/history/cycle6-start/Model.lean
/work/history/cycle6-start/candidate.json
/work/history/cycle5-start/Model.lean
/work/history/cycle5-start/candidate.json
/work/history/cycle7-start/Model.lean
/work/history/cycle7-start/candidate.json
/work/history/cycle1/human-feedback.json
/work/history/cycle1/Model.lean
/work/history/cycle1/candidate.json
/work/history/cycle2/human-feedback.json
/work/history/cycle2/Model.lean
/work/history/cycle2/candidate.json
/work/history/cycle8-start/Model.lean
/work/history/cycle8-start/candidate.json
/work/history/cycle3/human-feedback.json
/work/history/cycle3/Model.lean
/work/history/cycle3/candidate.json
/work/evidence/cycle7/revision-notes.txt
/work/evidence/cycle6/revision-notes.txt
/work/evidence/cycle8/revision-notes.txt
/work/evidence/cycle4/research-notes.txt
/work/candidate.json
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle8/revision-notes.txt /work/inputs/material-calculation-003/DIAGNOSTIC-NOTES.txt /work/lean-env.sh'"
}
shell output · exit 0
Cycle 8: review and analytical reduction; NOT a new candidate or acceptance.

Read the current host human decisions and all three supplied response records. Read material-calculation-003 DIAGNOSTIC-NOTES.txt, its full archer_diagnostic.py and raw JSON. Read cycle7 revision notes, the historical Model.lean and candidate, primary PartII searchable equations/reference sections, and previous actual check verdicts. Latest checked historical proof was 0a52ddc3554b4e10b6c5b477fceb0093: proved; subsequent human rejection remains binding. Extraction failures and elaboration failures remain preserved in /work/checks; the latest historical pass repaired them, but did not repair the scientific approximation. No new Lean check or material certificate is claimed this cycle. Archived the unchanged historical public files in history/cycle8-start.

New evidence incorporated for analysis: response 385ae674960d48e49d45526c2703465f. It is a diagnostic variant, not original Archer/Hill: consistent IAPWS95 substitution, corrected Pytzer interactions. It reports no uniform numerical or empirical bound. At 19,20,25,60,100 C, respectively, its step=.05 enthalpy differences d are 4933.4134,4851.9938,4477.1545,2650.7575,790.2965 J/mol. These are samples only. Cp_app samples are negative. Neither fact establishes a uniform-temperature sign. Derivative-step agreement is no truncation/roundoff certificate. Phase roots 99.60593 and99.76644 C are also diagnostics, not certified liquid domains. No freezing/solubility calculation was supplied. No measurements or other agents used.

Model lineage: the effective secant capacity, interpolated Partanen concentration correction, extrapolated Criss-Cobble enthalpy and constant solid capacity of the old candidate remain rejected. Do not reuse them. Current development uses full temperature-dependent enthalpies. The new IAPWS-substituted representation is a proposed explicit empirical model change only; its numerical enclosure would not validate its empirical accuracy or identify it with original Archer/Hill. Keep full m dependence and fixed 20C stored-solid reference.

Analytical reduction for a future proof, not yet a Lean theorem:
U(T)=water+pot enthalpy; V(T)=brine+pot enthalpy; K=enthalpy of stored solid at20C. Define D(T)=V(T)-U(T)-K=n*d(T). U',V'>0 on the applicable liquid intervals. Instantaneous adiabatic mixing is V(z(x))=U(x)+K. Strict increase of V implies z(x)<=x iff D(x)>=0. It also implies z increases with x. With common net power N(T)=W-k*(T-20), N(z)-N(x)=k*(x-z); this derives the after/before relationship and does not presume cooling or the sign of Cp_app.

Let F'(T)=U'(T)/N(T), G'(T)=V'(T)/N(T) be the inverse first-law time primitives, not fitted times. Tau(x)=F(x)-F(20)+G(B)-G(z(x)). Differentiating the mixing balance gives V'(z)*z'=U'(x). Hence tau'=U'(x)*(1/N(x)-1/N(z)). On positive-power paths with k>=0 and D>=0 this is nonnegative. With k=0 the derivative vanishes regardless of D. With k>0, its sign is sign(D). This argument permits either sign and arbitrary temperature variation of V'-U'; no constant-capacity reduction is needed. A global minimum at20C requires a bound on D across the entire admissible addition-temperature interval, not merely its sign at20C or at samples.

A derivative-free time comparison is also possible in energy coordinates: salt and water follow different inverse enthalpy temperatures at the SAME total energy. Earlier addition replaces a pure-water segment by a brine segment. If D>=0 and V is increasing, the brine temperature at the same energy is lower, N is larger, and the reciprocal power integrated over that segment is smaller. This gives the same criterion without differentiating the mixing inverse. It still requires a uniform material bound and feasible states, and is not a way to omit them.

Further cancellation, independently derived from the diagnostic code/reference identities:
Let Tr=298.15 K, Ts=293.15 K, mr=6 mol/kg, A(T)=h_ref_primitive(T), L(T,m)=L_phi(T,m), hw(T)=pure-water specific enthalpy J/kg, Icr=integral(Ts,Tr)Cp_cr.
d(T)=Hinf+Icr+A(T)-A(Tr)-(hw(T)-hw(Tr))/6 +L(T,m)-L(T,6)+L(Tr,6).
Here Hinf=Gdiss(Tr)+Tr*(Ssolute(Tr)-Ssolid(Tr))=3852.924825 J/mol. L(Tr,m) cancels. This form needs no quadrature of aqueous capacity, no high-temperature solid enthalpy, and no interpolated/extrapolated standard dissolution table. An interval evaluation of this direct formula only needs density/enthalpy and first density derivative for L; capacity bounds additionally need second density derivatives (analytic/automatic differentiation rather than finite differences). Numerical d bounds should be computed by interval partition with rigorously enclosed implicit water roots, derivative formulas, exp/log/powers, reference constants and the small solid integral. Grid extrema alone remain insufficient.

Needed material certificate is now focused: evaluate this declared representation at the derived composition, obtain actual enclosures for d(T) over20..100C, and coarse bounds on water Cp and Cp_app over19..100C. A certificate may report inconclusive sign. Finite sample extrema must not become assumptions claimed as proved. Empirical model validity is separate, remains reviewable even after exact arithmetic certification, and no original-Hill equivalence is asserted.

Feasibility reduction once material bounds exist: U'=mass*Cpwater+Cp_pot; V'=U'+n*Cp_app, with Cp_pot>=0. Bounds on components derive positive U',V'; do not assume C>=3900. A cooling bound D<=dmax*n and a positive lower V' imply x-z<=D/Vmin, keeping the initial mixed state above19C if D(20)<Vmin*1K. Monotonic z then gives z(x)>=z(20). If D>=0, z(x)<=x<=B0<=B. Heating may end at pure-water boiling onset but may not wait through it. All initial water, mixed brine and final trajectories must lie in their respective phase domains. Apparatus remains unspecified: positive input/loss coefficient, enough input to maintain N>0 up to B, shared Newtonian loss, nonnegative pot capacity, and no material loss. No duration can be inferred from original information.

Next action is a targeted calculation request for certified enclosures of the direct formula and component capacities, preserving failure/inconclusive output. No new candidate is submitted, and historical candidate.json remains archived/rejected rather than endorsed. Formalization and real harness check must follow receipt of a suitable certificate; no unconditional timing recommendation or human approval is claimed.
Requested material calculation: reproducible diagnostic variant

The supplied archer_diagnostic.py and archer-diagnostic-results.json are an operator calculation, not a physical experiment, another scientist's answer, or a formal certificate. They retain the 10 g NaCl / 0.99820675 kg water / 0.100 MPa case and derive molality. No timing conclusion or Lean proof is supplied.

Important model change: no tested implementation of the original Hill1990 water representation was available. This calculation consistently substitutes IAPWS95 water density, enthalpy and heat capacity in the Archer reference formulas and in the Archer-Wang dielectric calculation. It is not exact reproduction of the original Archer/Hill model. Treat it as an explicitly changed empirical representation, and decide whether that representation supports a defensible proof/model. The substitution must remain visible in provenance and cannot be silently identified with the original paper.

The two interaction functions are selected from the retained Pytzer parameter source by AST. Its documented corrections include publication sign/temperature-factor errors and a Rard-letter coefficient. The primary software source is https://github.com/mvdh7/pytzer/blob/main/pytzer/parameters/__init__.py . The source retains its GPLv3 notice. This evidence code is not added to the published harness. Reproduction:
uv run --with iapws==1.5.5 --with scipy==1.18.1 --with mpmath==1.4.1 --with click==8.5.1 python archer_diagnostic.py --out reproduced-results.json
Keep the retained pytzer-parameters.py beside the script; the other two retained Pytzer files are provenance and are hashed by the script. The script reads only two inspected pure functions, not arbitrary module-level code.

Numerical derivative steps 0.1, 0.05, 0.025 K are diagnostic convergence checks. They are not interval arithmetic or outward-rounded bounds. No uniform enclosure of d, C_app, water capacity, brine capacity, phase domain, solubility, or empirical error has been certified. Do not convert extrema of these five temperatures into global assumptions reported as proved bounds.

The raw Table7 comparisons are retained, including discrepancies: at273 K printed beta0 is0.06542 whereas the corrected software gives0.0645233; at323 K printed C1 is0.00639 whereas the corrected software gives0.00637970. Consequently this is not a claim that every table entry agrees to its last digit. Source transcription, corrected representation and original printed tables are distinct objects. Solid Cp from the natural-spline transcription agrees with Table4 at298.15 K to its displayed rounding (50.155875 versus50.16 J/mol/K).

The apparent-property reference uses the high-density liquid-water branch above the pure-water boiling point; at100 C this is metastable reference water at0.100 MPa. Diagnostic phase roots are99.60593 C for pure water and99.76644 C for this brine. No stable pure-water heating path through100 C is asserted. Freezing and solubility limits were not computed. Reprints alone do not turn this numerical phase diagnostic into a formal liquid-domain proof.

You may install ordinary free scientific tools inside the writable /work tree if useful. This supplies the requested calculation to the extent actually achieved, with its model substitution and unresolved numerical certification explicit. Preserve your independence in choosing and proving the scientific model. If a remaining bound is an empirical modeling guard rather than a derived result, identify it plainly and support it; do not assume the timing answer itself. No acceptance or prescribed optimum is given by this response.
export LEAN_PATH=/harness/.lake/packages/plausible/.lake/build/lib/lean:/harness/.lake/packages/proofwidgets/.lake/build/lib/lean:/harness/.lake/packages/LeanSearchClient/.lake/build/lib/lean:/harness/.lake/packages/mathlib/.lake/build/lib/lean:/harness/.lake/packages/aesop/.lake/build/lib/lean:/harness/.lake/packages/batteries/.lake/build/lib/lean:/harness/.lake/packages/importGraph/.lake/build/lib/lean:/harness/.lake/packages/Qq/.lake/build/lib/lean
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/Model.lean'"
}
shell output · exit 0
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢
  dsimp only [initialTemperature] at hW ⊢
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
shell input
{
  "command": "/usr/bin/bash -lc 'ls /work/inputs/material-literature-002; cat /work/inputs/material-literature-002/READING-NOTES.txt; ls /work/checks'"
}
shell output · exit 0
READING-NOTES.txt
archer-1992-part1-crystalline.pdf
archer-1992-part1-crystalline.txt
archer-1992-part2-solution.pdf
archer-1992-part2-solution.txt
archer-solid-knots.csv
parker-1965-nsrds2.pdf
parker-1965-nsrds2.txt
parker-apparent-heat-capacity.csv
parker-enthalpy-infinity.png
parker-heat-capacity.png
parker-relative-enthalpy-25C.csv
parker-table-X.png
part1-eqs.png
part1-knots.png
part2-coefficients.png
part2-definitions.png
part2-enthalpy-capacity.png
part2-temperature-functions.png
sources.json
Primary thermodynamic literature supplied by the operator, 18 November 2026

This is literature and source transcription, not a physical experiment or a timing recommendation. It contains no other scientist's model, proof or answer. PDF page numbers below are one-based and include front matter.

Parker, Thermal Properties of Aqueous Uni-univalent Electrolytes, NSRDS-NBS 2 (1965), DOI 10.6028/NBS.NSRDS.2.
https://nvlpubs.nist.gov/nistpubs/Legacy/NSRDS/nbsnsrds2.pdf
Printed p26 / PDF p34: NaCl(cr) infinite-dilution dissolution enthalpy at 25 C is +928 +/-5 cal/mol. Table X, printed p50 / PDF p58, gives the relative apparent molar enthalpy Phi_L at 25 C. Table II C, printed p43 / PDF p51, gives the apparent molar heat capacity Phi_C at 15,20,25,30 C. Table XIX, printed p64 / PDF p72, lists contributing infinite-dilution results. Source units are thermochemical calories: 1 cal=4.1840 J. Phi_L is relative to infinite dilution, not the complete dissolution enthalpy; Phi_C is apparent heat capacity, not the solid's heat capacity. Sparse table entries do not establish interpolation, a derivative between rows, or a temperature-uniform enclosure. See the CSVs and original page images. The quoted +/-5 is Parker's uncertainty statement, not a certified uniform error for an interpolating model.

Archer, Thermodynamic Properties of the NaCl+H2O System, Part I: NaCl(cr), JPCRD21,1-21 (1992), DOI 10.1063/1.555913.
https://srd.nist.gov/jpcrdreprint/1.555913.pdf
Printed p4 / PDF p5, Eqs4-6: fit f(T) with a natural cubic spline; b=.25, T0=1 K, Cp0=1 J/(mol K); Cp_cr/Cp0=[T/(T0*f(T)+b*T)]^3. Table3, printed p11 / PDF p12, supplies all knot abscissas and values (see archer-solid-knots.csv); both end conditions are natural. This is a spline of the transformed f, not a piecewise-linear fit of Cp. Table4, printed p15 / PDF p16, supplies numerical checks, including Cp(298.15K)=50.16 J/(mol K). Solid enthalpy increments follow from integrating the defined heat capacity. Printed p12 discusses empirical accuracy: the roughly .3% statement applies to 300..800K; do not apply it automatically below 300K. This representation differs from the older JANAF value 50.509 at 298.15K. Keep one declared thermodynamic reference or account for differences.

Archer, Part II: NaCl(aq), NaCl.2H2O(cr), and phase equilibria, JPCRD21,793-829 (1992), DOI 10.1063/1.555915.
https://srd.nist.gov/jpcrdreprint/1.555915.pdf
Printed p796 / PDF p5: Eq2 explicitly uses Part I's solid heat-capacity integrals, Tr=298.15K, pr=.1MPa. Section4.1, printed pp797-801 / PDF pp6-10, supplies the modified ion-interaction model. Eq9 is relative apparent enthalpy; Eq12 is apparent molar heat capacity; Eq20 defines an apparent property. Eqs21-22 retain the reference solution at mr=6 mol/kg; Eqs32-38 define the temperature/pressure functions; Table2 gives coefficients. Eq38's heat-capacity scale is 1 kJ/(mol K), not 1 J/(mol K). Table2's anhydrous -9.040721 kJ/mol parameter is a Gibbs-energy anchor, not a dissolution-enthalpy anchor. Eq2's solid entropy at Tr is 72.2653 J/(mol K); the solute entropy in Table2 is 115.5108 J/(mol K). Check conversion to enthalpy rather than substituting G for H. Blank coefficient entries are omitted terms. Pages798-801 have been rendered for inspecting symbols and signs. Original model uses Hill's water EOS and the dielectric relation of Archer/Wang (references3,14), with Debye-Huckel definitions from Bradley/Pitzer (reference15). Substituting another water representation is a model change to document. Validation tables and phase-equilibrium section5 are included in the full article. The fitted data span approximately250..600K; physical liquid-phase validity still needs checking at the chosen pressure/composition.

Operator boundaries for use

The source pages, table units, selected Parker entries and Part I knot values were visually inspected. The full aqueous EOS has not been implemented or numerically certified by the operator. No grid evaluation, extremum, certified interval enclosure, pure-water/brine boiling interval or uniform capacity bound is supplied. Implement and derive the material model from the primary equations, retain your calculation provenance, and prove the consequences needed in Lean. State any indispensable missing primary coefficient explicitly rather than selecting a favorable sign or treating sparse table samples as bounds.

Use consistent definitions of isothermal dissolution from same-temperature reactants, the stored solid's sensible enthalpy, absolute apparent heat capacity and relative infinite-dilution corrections. A sparse-temperature secant is not a local heat-capacity law. Phase boundaries must follow from pressure and composition; do not assume the brine boiling point is below100C. Keep apparatus assumptions separate from property evidence. This literature response does not approve a model or conclusion.
0a52ddc3554b4e10b6c5b477fceb0093
19e916da3a2f417381acb479d8151af9
3366e6e934024e17b8832b7253fbd31c
45e3bdc1f6974c4dae446c78777c9f79
8ce875bbeedf40f384474d008e4dfa66
cd3bf32329e547d19d474c1bd79431b9
eb1f4719481a42c1a8b798b0b91aca4d
f49ea96bd5de45babf8f3c699ba15e09
fa26349a1ab0402c9d16ff1354b2240b
shell input
{
  "command": "/usr/bin/bash -lc \"rg -n '4481|3824|84.98|95.18|Table 8|Table 2|19.97' /work/inputs/material-evidence-001/partanen-2023-enthalpy.txt\""
}
shell output · exit 127 · failed
/usr/bin/bash: line 1: rg: command not found
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/inputs/material-literature-002/parker-apparent-heat-capacity.csv /work/inputs/material-literature-002/parker-relative-enthalpy-25C.csv; cat /work/inputs/material-calculation-004/interval-certification-status.json; cat /work/checks/0a52ddc3554b4e10b6c5b477fceb0093/*json'"
}
shell output · exit 0
molality_mol_per_kg,Phi_C_15C_cal_per_mol_K,Phi_C_20C_cal_per_mol_K,Phi_C_25C_cal_per_mol_K,Phi_C_30C_cal_per_mol_K
0,-25.2,-23.3,-21.5,-20.1
0.1388,-21.4,-19.8,-18.2,-16.9
0.1850,-20.5,-19.0,-17.5,-16.2
0.2775,-19.0,-17.5,-16.3,-15.1
0.3700,-17.7,-16.4,-15.2,-14.1
0.5551,-15.5,-14.8,-13.4,-12.5
0.7401,-13.6,-12.6,-11.7,-10.9
1.1101,-10.4,-9.6,-8.8,-8.2
molality_mol_per_kg,Phi_L_cal_per_mol
0,0
0.1388,87
0.1850,88
0.2775,83
0.5551,49
0.7401,20
1.1101,-41
{
  "request_id": "e619fbb0992b47fab14c4641bd0dcbf2",
  "status": "not_certified",
  "kind": "operational failure record, not a mathematical impossibility certificate",
  "calculation_retained": "archer_diagnostic.py with archer-diagnostic-results.json",
  "direct_d_reduction": "Algebraic cancellation of Lphi(Tr,m) in the supplied implementation is valid. A is an antiderivative of cp_ref, water h is J/kg and division by mr6 gives J/mol; the solid increment uses the stored20C reference.",
  "unresolved_operations": [
    "The SciPy liquid-density root has no outward-rounded interval enclosure over each temperature subinterval.",
    "The root derivative denominators have not been bounded away from zero uniformly.",
    "The AW90/IAPWS95 Aphi first and second temperature derivatives still use finite differences, with no uniform truncation/roundoff bound.",
    "Solid-spline quadrature, reference enthalpy differences and phase-root calculations are floating-point diagnostics, without interval or analytic remainder bounds.",
    "No complete liquid/solubility-domain certificate has been constructed for the modified representation."
  ],
  "certified_uniform_d_bounds": null,
  "certified_uniform_Capp_bounds": null,
  "certified_phase_brackets": null,
  "empirical_accuracy": "Numerical certification would establish properties of the declared changed representation, not its physical error. No physical-accuracy guarantee was derived.",
  "no_new_samples_misreported_as_bounds": true
}
{
 "file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean",
 "conclusions": [
  "nacl_immediate_addition_answer"
 ],
 "lean_exit": 0,
 "ok": true,
 "compiles_alone": true,
 "faithful": {
  "nacl_immediate_addition_answer": true
 },
 "assumption_declarations": [
  "initialTemperature",
  "netPower",
  "mixedTemperature",
  "heatingTime",
  "boilingTime",
  "naclRelativeEnthalpy",
  "naclDissolutionAt20",
  "naclCapacityChange"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "nacl_immediate_addition_answer": {
   "original_sha256": "5a458dff2d8b618009ca0d3584944b20e164a2f1014b272491283e0cc96533b7",
   "extracted_sha256": "5a458dff2d8b618009ca0d3584944b20e164a2f1014b272491283e0cc96533b7"
  }
 },
 "dependency_faithful": {
  "initialTemperature": true,
  "initialTemperature._proof_1": true,
  "naclCapacityChange": true,
  "naclRelativeEnthalpy._proof_1": true,
  "naclCapacityChange._proof_1": true,
  "naclCapacityChange._proof_2": true,
  "naclCapacityChange._proof_3": true,
  "naclCapacityChange._proof_4": true,
  "naclRelativeEnthalpy": true,
  "naclRelativeEnthalpy._proof_2": true,
  "naclRelativeEnthalpy._proof_3": true,
  "naclRelativeEnthalpy._proof_4": true,
  "naclDissolutionAt20": true,
  "naclDissolutionAt20._proof_1": true,
  "naclDissolutionAt20._proof_2": true,
  "naclDissolutionAt20._proof_3": true,
  "naclCapacityChange._proof_5": true,
  "mixedTemperature": true,
  "netPower": true,
  "boilingTime": true,
  "heatingTime": true
 },
 "dependency_identities": {
  "initialTemperature": {
   "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
   "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
  },
  "initialTemperature._proof_1": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "naclCapacityChange": {
   "original_sha256": "8670a93d0602bcf463a61fee28b4b0132903fa86b5e02063d783a457e0e20d95",
   "extracted_sha256": "8670a93d0602bcf463a61fee28b4b0132903fa86b5e02063d783a457e0e20d95"
  },
  "naclRelativeEnthalpy._proof_1": {
   "original_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e",
   "extracted_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e"
  },
  "naclCapacityChange._proof_1": {
   "original_sha256": "eeb571f066f9fd41079c19239c0556ae7d3640be2b5a3e6c76d862f948944a3d",
   "extracted_sha256": "eeb571f066f9fd41079c19239c0556ae7d3640be2b5a3e6c76d862f948944a3d"
  },
  "naclCapacityChange._proof_2": {
   "original_sha256": "7bb889d46cc76bcb2cc9e5e670df469595a74df8cf7126322071ab7c0be53472",
   "extracted_sha256": "7bb889d46cc76bcb2cc9e5e670df469595a74df8cf7126322071ab7c0be53472"
  },
  "naclCapacityChange._proof_3": {
   "original_sha256": "2ba7335cd3609ac74f89befa6e2bece6c16a746f1305f1fad2a3147c66ccbd9e",
   "extracted_sha256": "2ba7335cd3609ac74f89befa6e2bece6c16a746f1305f1fad2a3147c66ccbd9e"
  },
  "naclCapacityChange._proof_4": {
   "original_sha256": "95a4b8dc8de5704474a04eac7090e59fc6f0dc381b86621ea7b579a8aa989d48",
   "extracted_sha256": "95a4b8dc8de5704474a04eac7090e59fc6f0dc381b86621ea7b579a8aa989d48"
  },
  "naclRelativeEnthalpy": {
   "original_sha256": "241e6415aa135e0478293cafa7224aa561f642e34d34ff566230d5a0769af57e",
   "extracted_sha256": "241e6415aa135e0478293cafa7224aa561f642e34d34ff566230d5a0769af57e"
  },
  "naclRelativeEnthalpy._proof_2": {
   "original_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8",
   "extracted_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8"
  },
  "naclRelativeEnthalpy._proof_3": {
   "original_sha256": "39fafd58592e6f7d4b38f634565fbb6e9bbefe69aeeb93ddf7f184e06209bc4d",
   "extracted_sha256": "39fafd58592e6f7d4b38f634565fbb6e9bbefe69aeeb93ddf7f184e06209bc4d"
  },
  "naclRelativeEnthalpy._proof_4": {
   "original_sha256": "d2b35f180040d865daeefeff1cb2ec8fe91bba9d4feab29fa08cb1cfa9f06a13",
   "extracted_sha256": "d2b35f180040d865daeefeff1cb2ec8fe91bba9d4feab29fa08cb1cfa9f06a13"
  },
  "naclDissolutionAt20": {
   "original_sha256": "707be014e24f264bc42917b6e4b5fd07e07e1ddcc652e798ef1322c03c11d740",
   "extracted_sha256": "707be014e24f264bc42917b6e4b5fd07e07e1ddcc652e798ef1322c03c11d740"
  },
  "naclDissolutionAt20._proof_1": {
   "original_sha256": "d26507b0493f14007ca36940f4f486d4f8a4042b7d1750e0d82a0fc7cd37e327",
   "extracted_sha256": "d26507b0493f14007ca36940f4f486d4f8a4042b7d1750e0d82a0fc7cd37e327"
  },
  "naclDissolutionAt20._proof_2": {
   "original_sha256": "f5c712256be2eb371af21a0efe29a66a19279c2854a6d5728c3b1c27261e70b9",
   "extracted_sha256": "f5c712256be2eb371af21a0efe29a66a19279c2854a6d5728c3b1c27261e70b9"
  },
  "naclDissolutionAt20._proof_3": {
   "original_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae",
   "extracted_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae"
  },
  "naclCapacityChange._proof_5": {
   "original_sha256": "6a4d87025b5494d28bb170c00a0004de722e9ecc9d872d9068b023a8a066c4f0",
   "extracted_sha256": "6a4d87025b5494d28bb170c00a0004de722e9ecc9d872d9068b023a8a066c4f0"
  },
  "mixedTemperature": {
   "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
   "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
  },
  "netPower": {
   "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
   "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
  },
  "boilingTime": {
   "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
   "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
  },
  "heatingTime": {
   "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
   "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "nacl_immediate_addition_answer": "\u2200 (C W k B0 B x : \u211d), \u21913900 \u2264 C \u2192 0 < k \u2192 \u219199 \u2264 B0 \u2192 B0 \u2264 \u21911001 / \u219110 \u2192 B0 \u2264 B \u2192 B \u2264 \u2191101 \u2192 k * (B - initialTemperature) < W \u2192 x \u2208 Set.Icc initialTemperature B0 \u2192 0 < C + naclCapacityChange \u2227 (\u219119 \u2264 mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x \u2227 mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x \u2264 x) \u2227 (0 < netPower W k initialTemperature x \u2227 netPower W k initialTemperature x < netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) \u2227 boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature \u2264 boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x"
 },
 "extracted_file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.lean",
 "errors": []
}{
  "proof_file": "Model.lean",
  "narrative_file": "report.txt",
  "conclusions": {
    "answer": "nacl_immediate_addition_answer"
  },
  "user_facts": [
    "One litre of water initially at 20 degrees Celsius is in a pot being heated on a stove.",
    "Salt will be added; salt quantity, pot, heater and room conditions otherwise unspecified."
  ],
  "model_choices": [
    "Scenario retained from cycle 4: 10 g pure dry crystalline NaCl held at 20 C before addition; ambient and initially equilibrated pot at 20 C; approximately atmospheric pressure. Nominal solvent mass .99820675 kg from NIST 20 C density and molar mass 58.443 g/mol determine .1714143 mol/kg.",
    "Use published Partanen2023 PI(con) relative enthalpy expression, interpolating its v,q between .15 and .20 mol/kg. Standard solid dissolution enthalpy at 20 C is interpolated from actual 19.97 and 25 C entries in its Table 8. Add same-temperature finite-concentration correction; derive H, do not assume its sign.",
    "Effective constant signed solution-minus-water heat capacity S is the 20-to-100 C apparent-enthalpy secant with solid salt referenced to 20 C. Standard dissolution enthalpy at 100 C is linearly extrapolated from 84.98 and 95.18 C values; solid sensible heat uses effective 51 J/(mol K), guided by NIST-JANAF. Derive S from these inputs, not from a preset sign. This affine effective enthalpy model is used on 19..101 C; it is a reduction, not a uniform local-capacity bound. Sampled residuals are disclosed; extrapolation and uniform physical accuracy have no certified uncertainty bound.",
    "Shared constant-input Newtonian heat flow N(T)=W-k*(T-20), k>0, unchanged by salinity. Heating obeys capacity*dT/dt=N(T); constant water+pot capacity C>=3900 J/K. Affine enthalpies, instantaneous adiabatic complete dissolution, no heating interruption, negligible evaporation and material loss; uniform liquid/pot temperature.",
    "Unsalted boiling B0 satisfies 99<=B0<=100.1 C; final brine boiling satisfies B0<=B<=101 C. Assume enough power W>k*(B-20). Compare all additions 20<=x<=B0, allowing only the onset of unsalted boiling without dwelling. Liquid/solubility applicability is explicit. The proof derives positive final capacity, postmix temperature>=19 C, postmix temperature<=x<=B, and positive heat flow."
  ],
  "sources": [
    "Operator source bundle /work/inputs/material-evidence-001/sources.json, with original PDFs/text and SHA256 hashes; response f7c987a52391410bb035542305825b3f.",
    "https://doi.org/10.1007/s10953-023-01322-y \u2014 Partanen2023 Eqs.13-19 and Tables 2,8; Table 8 attributes standard solid dissolution data to Criss and Cobble.",
    "https://doi.org/10.1007/s10953-024-01412-5 \u2014 Partanen2025 Eqs.9-10,18 and discussion of competing absolute heat-capacity baselines.",
    "https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf \u2014 GLP10 water density.",
    "https://janaf.nist.gov/tables/Cl-055.html \u2014 crystalline NaCl heat capacity.",
    "https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2 \u2014 molar mass and solid correlation validity limits.",
    "https://iapws.org/technical-guidance/release/IAPWS-95 \u2014 pure-water thermal and phase relationships."
  ],
  "incorporated_inputs": [
    "f7c987a52391410bb035542305825b3f"
  ],
  "proof_scope": "For the explicit literature-calibrated effective affine-enthalpy NaCl case, derives signed capacity/dissolution bounds, positive final capacity, feasible liquid mixing temperatures, net-power increase from energy conservation and the shared loss law, and immediate addition as a global minimizer over 20 C through onset of unsalted boiling. Retains signed-capacity and reference-consistent balance derivations, stage-time uniqueness from inverse energy balance, and full-schedule derivative/monotonicity proof. No sorry or additional axiom. Conditional on exposed empirical interpolation/extrapolation, effective constant-capacity reduction, phase and apparatus premises; does not certify their physical accuracy, infer a numerical duration, resolve all unspecified salts/apparatus, or claim human approval. Raw calculations and Lean diagnostics preserved in evidence/cycle5/."
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-17T23:45:21.072186+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean",
    "conclusions": [
      "nacl_immediate_addition_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "nacl_immediate_addition_answer": true
    },
    "assumption_declarations": [
      "initialTemperature",
      "netPower",
      "mixedTemperature",
      "heatingTime",
      "boilingTime",
      "naclRelativeEnthalpy",
      "naclDissolutionAt20",
      "naclCapacityChange"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "nacl_immediate_addition_answer": {
        "original_sha256": "5a458dff2d8b618009ca0d3584944b20e164a2f1014b272491283e0cc96533b7",
        "extracted_sha256": "5a458dff2d8b618009ca0d3584944b20e164a2f1014b272491283e0cc96533b7"
      }
    },
    "dependency_faithful": {
      "initialTemperature": true,
      "initialTemperature._proof_1": true,
      "naclCapacityChange": true,
      "naclRelativeEnthalpy._proof_1": true,
      "naclCapacityChange._proof_1": true,
      "naclCapacityChange._proof_2": true,
      "naclCapacityChange._proof_3": true,
      "naclCapacityChange._proof_4": true,
      "naclRelativeEnthalpy": true,
      "naclRelativeEnthalpy._proof_2": true,
      "naclRelativeEnthalpy._proof_3": true,
      "naclRelativeEnthalpy._proof_4": true,
      "naclDissolutionAt20": true,
      "naclDissolutionAt20._proof_1": true,
      "naclDissolutionAt20._proof_2": true,
      "naclDissolutionAt20._proof_3": true,
      "naclCapacityChange._proof_5": true,
      "mixedTemperature": true,
      "netPower": true,
      "boilingTime": true,
      "heatingTime": true
    },
    "dependency_identities": {
      "initialTemperature": {
        "original_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea",
        "extracted_sha256": "b652262b722f84a0ebd22f567fe5efb61eb2f05ebdf821f7063e94129562acea"
      },
      "initialTemperature._proof_1": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "naclCapacityChange": {
        "original_sha256": "8670a93d0602bcf463a61fee28b4b0132903fa86b5e02063d783a457e0e20d95",
        "extracted_sha256": "8670a93d0602bcf463a61fee28b4b0132903fa86b5e02063d783a457e0e20d95"
      },
      "naclRelativeEnthalpy._proof_1": {
        "original_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e",
        "extracted_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e"
      },
      "naclCapacityChange._proof_1": {
        "original_sha256": "eeb571f066f9fd41079c19239c0556ae7d3640be2b5a3e6c76d862f948944a3d",
        "extracted_sha256": "eeb571f066f9fd41079c19239c0556ae7d3640be2b5a3e6c76d862f948944a3d"
      },
      "naclCapacityChange._proof_2": {
        "original_sha256": "7bb889d46cc76bcb2cc9e5e670df469595a74df8cf7126322071ab7c0be53472",
        "extracted_sha256": "7bb889d46cc76bcb2cc9e5e670df469595a74df8cf7126322071ab7c0be53472"
      },
      "naclCapacityChange._proof_3": {
        "original_sha256": "2ba7335cd3609ac74f89befa6e2bece6c16a746f1305f1fad2a3147c66ccbd9e",
        "extracted_sha256": "2ba7335cd3609ac74f89befa6e2bece6c16a746f1305f1fad2a3147c66ccbd9e"
      },
      "naclCapacityChange._proof_4": {
        "original_sha256": "95a4b8dc8de5704474a04eac7090e59fc6f0dc381b86621ea7b579a8aa989d48",
        "extracted_sha256": "95a4b8dc8de5704474a04eac7090e59fc6f0dc381b86621ea7b579a8aa989d48"
      },
      "naclRelativeEnthalpy": {
        "original_sha256": "241e6415aa135e0478293cafa7224aa561f642e34d34ff566230d5a0769af57e",
        "extracted_sha256": "241e6415aa135e0478293cafa7224aa561f642e34d34ff566230d5a0769af57e"
      },
      "naclRelativeEnthalpy._proof_2": {
        "original_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8",
        "extracted_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8"
      },
      "naclRelativeEnthalpy._proof_3": {
        "original_sha256": "39fafd58592e6f7d4b38f634565fbb6e9bbefe69aeeb93ddf7f184e06209bc4d",
        "extracted_sha256": "39fafd58592e6f7d4b38f634565fbb6e9bbefe69aeeb93ddf7f184e06209bc4d"
      },
      "naclRelativeEnthalpy._proof_4": {
        "original_sha256": "d2b35f180040d865daeefeff1cb2ec8fe91bba9d4feab29fa08cb1cfa9f06a13",
        "extracted_sha256": "d2b35f180040d865daeefeff1cb2ec8fe91bba9d4feab29fa08cb1cfa9f06a13"
      },
      "naclDissolutionAt20": {
        "original_sha256": "707be014e24f264bc42917b6e4b5fd07e07e1ddcc652e798ef1322c03c11d740",
        "extracted_sha256": "707be014e24f264bc42917b6e4b5fd07e07e1ddcc652e798ef1322c03c11d740"
      },
      "naclDissolutionAt20._proof_1": {
        "original_sha256": "d26507b0493f14007ca36940f4f486d4f8a4042b7d1750e0d82a0fc7cd37e327",
        "extracted_sha256": "d26507b0493f14007ca36940f4f486d4f8a4042b7d1750e0d82a0fc7cd37e327"
      },
      "naclDissolutionAt20._proof_2": {
        "original_sha256": "f5c712256be2eb371af21a0efe29a66a19279c2854a6d5728c3b1c27261e70b9",
        "extracted_sha256": "f5c712256be2eb371af21a0efe29a66a19279c2854a6d5728c3b1c27261e70b9"
      },
      "naclDissolutionAt20._proof_3": {
        "original_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae",
        "extracted_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae"
      },
      "naclCapacityChange._proof_5": {
        "original_sha256": "6a4d87025b5494d28bb170c00a0004de722e9ecc9d872d9068b023a8a066c4f0",
        "extracted_sha256": "6a4d87025b5494d28bb170c00a0004de722e9ecc9d872d9068b023a8a066c4f0"
      },
      "mixedTemperature": {
        "original_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599",
        "extracted_sha256": "47a9008b9cefb902aef363df20fb6421140ea1fc30f3854b8c44464c3385c599"
      },
      "netPower": {
        "original_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee",
        "extracted_sha256": "b9c0bbe8f806f6de3549cfbfb2d5bfa06897bfd39fe5efd76d6ae51d78ca26ee"
      },
      "boilingTime": {
        "original_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8",
        "extracted_sha256": "c2066b5182c1d378e6d7b26a5800ac840e1db0a31387803870767329b37cdfe8"
      },
      "heatingTime": {
        "original_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f",
        "extracted_sha256": "54cbe1fec2ed290760adf57de1bd0ba53cb45bbb4d284aab41163f266851b14f"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "nacl_immediate_addition_answer": "\u2200 (C W k B0 B x : \u211d), \u21913900 \u2264 C \u2192 0 < k \u2192 \u219199 \u2264 B0 \u2192 B0 \u2264 \u21911001 / \u219110 \u2192 B0 \u2264 B \u2192 B \u2264 \u2191101 \u2192 k * (B - initialTemperature) < W \u2192 x \u2208 Set.Icc initialTemperature B0 \u2192 0 < C + naclCapacityChange \u2227 (\u219119 \u2264 mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x \u2227 mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x \u2264 x) \u2227 (0 < netPower W k initialTemperature x \u2227 netPower W k initialTemperature x < netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) \u2227 boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature \u2264 boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x"
    },
    "extracted_file": "/work/checks/0a52ddc3554b4e10b6c5b477fceb0093/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
assistant
The interval-certification attempt failed, so the Archer diagnostic samples cannot establish a uniform sign. I’ll use the supplied Parker calorimetry to fit a simpler temperature-dependent model and prove its timing implications. Extending that fit beyond the measured temperatures will remain an explicit, unvalidated assumption; the recommendation will be conditional on it.
shell input
{
  "command": "/usr/bin/bash -lc 'mkdir -p /work/history/cycle9-start /work/evidence/cycle9; cp /work/Model.lean /work/candidate.json /work/report.txt /work/history/cycle9-start/; which lean; ls /harness; cat /work/inputs/material-literature-002/sources.json'"
}
shell output · exit 0
entrypoint.sh
lean-toolchain
src
{
  "created_utc": "2026-11-18T00:49:25.405175+00:00",
  "purpose": "Primary material-property literature; no experiment, timing recommendation, peer result or certified EOS bound supplied",
  "sources": [
    {
      "file": "archer-1992-part1-crystalline.pdf",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555913.pdf",
      "doi": "10.1063/1.555913",
      "bytes": 1916292,
      "sha256": "c3d73a33e8e9f7cbc041ef32a3cc68d6f8973aeb285e5b248c97920c971681c8"
    },
    {
      "file": "archer-1992-part2-solution.pdf",
      "url": "https://srd.nist.gov/jpcrdreprint/1.555915.pdf",
      "doi": "10.1063/1.555915",
      "bytes": 3393563,
      "sha256": "a814e0cee1b80352619a12324e4355d4253a50ca9fcc86be26b3d32865c098f5"
    },
    {
      "file": "parker-1965-nsrds2.pdf",
      "url": "https://nvlpubs.nist.gov/nistpubs/Legacy/NSRDS/nbsnsrds2.pdf",
      "doi": "10.6028/NBS.NSRDS.2",
      "bytes": 5496010,
      "sha256": "6e5a30917ba61a22e542766195b71e0b3cfd7463a0c6ae11b97ffdd1f8b88743"
    }
  ],
  "visual_inspection": [
    "part1-eqs.png",
    "part1-knots.png",
    "part2-coefficients.png",
    "part2-definitions.png",
    "part2-enthalpy-capacity.png",
    "part2-temperature-functions.png",
    "parker-table-X.png",
    "parker-heat-capacity.png",
    "parker-enthalpy-infinity.png"
  ],
  "retrieval_notes": [
    "Initial plain urllib request returned HTTP403; successful retry used a normal browser user-agent with TLS verification enabled.",
    "A guessed NIST mirror filename returned an unrelated PDF and was discarded. Part II was fetched again from the verified DOI reprint URL and its title/text checked."
  ],
  "files": {
    "READING-NOTES.txt": {
      "sha256": "9dcfa3c0855752fd4e39331c21f32c7732b9a3d05f80840fecf17de4e810045c",
      "bytes": 4890
    },
    "archer-1992-part1-crystalline.pdf": {
      "sha256": "c3d73a33e8e9f7cbc041ef32a3cc68d6f8973aeb285e5b248c97920c971681c8",
      "bytes": 1916292
    },
    "archer-1992-part1-crystalline.txt": {
      "sha256": "8c297d73c003642be355f6911d99ed618b3dd09e59c7573fd522fb7b1e35a81c",
      "bytes": 118876
    },
    "archer-1992-part2-solution.pdf": {
      "sha256": "a814e0cee1b80352619a12324e4355d4253a50ca9fcc86be26b3d32865c098f5",
      "bytes": 3393563
    },
    "archer-1992-part2-solution.txt": {
      "sha256": "31ee833327932f95837944fe7f2d3b96ea436039a3ce1d8b2fe131f631cb1dab",
      "bytes": 278447
    },
    "archer-solid-knots.csv": {
      "sha256": "ed9d5f49ff75434e01385322878f4bfd1881ddccaf99c20f47210e859466eeb7",
      "bytes": 158
    },
    "parker-1965-nsrds2.pdf": {
      "sha256": "6e5a30917ba61a22e542766195b71e0b3cfd7463a0c6ae11b97ffdd1f8b88743",
      "bytes": 5496010
    },
    "parker-1965-nsrds2.txt": {
      "sha256": "f9903f6e36366b1b71da1d20447b44cb6acfab069383ca75be475afc16ad7b0b",
      "bytes": 538802
    },
    "parker-apparent-heat-capacity.csv": {
      "sha256": "2ffdd877837ac12e182b59a73ba683535773f9c91f4f1e9913c5b816beb9b986",
      "bytes": 356
    },
    "parker-enthalpy-infinity.png": {
      "sha256": "0d824a7d691c99c708e2d98c686b140d46d63d822f47488795e99311d6c7404c",
      "bytes": 1455467
    },
    "parker-heat-capacity.png": {
      "sha256": "3104996970dd6a1ae6e0e4e1e16cac91ca85fb7bdd647bc8368a61d00e6aaa93",
      "bytes": 421070
    },
    "parker-relative-enthalpy-25C.csv": {
      "sha256": "4ae523c9b02c95afb672c683d1844995935f9bef10497cfa81a3e67e6b5fc9fc",
      "bytes": 103
    },
    "parker-table-X.png": {
      "sha256": "b499610ea47b5eddac5707d3a536779b5a7288f6bc501d15841a37843dd4180b",
      "bytes": 660566
    },
    "part1-eqs.png": {
      "sha256": "8c32d07adbcb76f53cd8c11f2770ec4100411405f7afc08f4caabbee25435082",
      "bytes": 223114
    },
    "part1-knots.png": {
      "sha256": "b6d17dccdcebd93775a3c9db0273cd6bb82694e877ed2b1486d75f6da211e472",
      "bytes": 262165
    },
    "part2-coefficients.png": {
      "sha256": "30d42e111e9e266e7b1ae91dd3177242b2a123405f23bd3e47f519e245aa74ca",
      "bytes": 150936
    },
    "part2-definitions.png": {
      "sha256": "d981636acf70a4008e9a1f43337bc7ee661dcda010c6efe7863e5bcb9fc172f5",
      "bytes": 199707
    },
    "part2-enthalpy-capacity.png": {
      "sha256": "94d2669dca823195bd66cd631eb8373d59e6de52dd0fc6f2fa616954b100579d",
      "bytes": 156604
    },
    "part2-temperature-functions.png": {
      "sha256": "609ecb83e48ba810ee139826a099ae813143bc35138068741881c0c5c9b5ed06",
      "bytes": 180657
    }
  }
}
shell input
{
  "command": "/usr/bin/bash -lc 'ls /opt/lean/bin /root/.elan/bin /home/[user]/.elan/bin 2>/dev/null; ls /harness/src; head -80 /harness/src/vcs_protocol.py'"
}
shell output · exit 0
/opt/lean/bin:
cadical
clang
con-leche
con-ron
lake
ld.lld
lean
lean4lean
leanc
leanchecker
leanchecker-paranoid
leanexport
leanir
leanmake
leantar
llvm-ar
nanoda_bin
vcs_extract.py
vcs_lean.py
vcs_protocol.py
"""Versioned, human-gated workflow for agent-written scientific Lean models.

Host control files never enter the scientist container. Container check results are
feedback only: host review always checks its own frozen snapshot independently.
"""
from __future__ import annotations

import hashlib
import json
import os
from decimal import Decimal, InvalidOperation
from pathlib import Path
import re
import shutil
import stat
import subprocess
import sys
import tempfile
import uuid
from datetime import datetime, timezone

import click

ROOT = Path(__file__).resolve().parents[1]
IMAGE = "sha256:c0e8df9380519cf514d5fbb5aeaa7aa5de5f32c50330badcadc05cdabaae5566"
CODEX_VERSION = "codex-cli 0.166.0"
CLAUDE_VERSION = "2.1.325 (Claude Code)"
DEFAULT_MODELS = {"codex": "gpt-6.1-sol", "claude": "claude-sonnet-5-5"}
CLAUDE_TOOLS = "Bash,Read,Write,Edit,Grep,Glob,WebFetch,WebSearch"
NAME = re.compile(r"[A-Za-z_][A-Za-z_0-9']*")


def digest(path):
    return hashlib.sha256(Path(path).read_bytes()).hexdigest()


def directory_fd(path, create=False):
    """Walk from root without following links, even in an untrusted workspace."""
    path = Path(path).absolute()
    if ".." in path.parts:
        raise ValueError("directory traversal is unsupported")
    fd = os.open("/", os.O_RDONLY | os.O_DIRECTORY)
    try:
        for part in path.parts[1:]:
            if create:
                try:
                    os.mkdir(part, mode=0o700, dir_fd=fd)
                except FileExistsError:
                    pass
            child = os.open(part, os.O_RDONLY | os.O_DIRECTORY | os.O_NOFOLLOW, dir_fd=fd)
            os.close(fd)
            fd = child
        return fd
    except BaseException:
        os.close(fd)
        raise


def ensure_directory(path):
    os.close(directory_fd(path, create=True))


def atomic_write(path, data):
    """Replace the directory entry; never open an existing target or predictable temp."""
    path = Path(path)
    parent = directory_fd(path.parent)
    temp = ".vcs-write-" + uuid.uuid4().hex
    try:
        try:
            existing = os.stat(path.name, dir_fd=parent, follow_symlinks=False)
        except FileNotFoundError:
            existing = None
        if existing is not None and stat.S_ISLNK(existing.st_mode):
            raise ValueError("refusing symlink write destination")
        fd = os.open(temp, os.O_WRONLY | os.O_CREAT | os.O_EXCL | os.O_NOFOLLOW,
                     0o600, dir_fd=parent)
        with os.fdopen(fd, "wb") as stream:
            stream.write(data)
        os.replace(temp, path.name, src_dir_fd=parent, dst_dir_fd=parent)
    finally:
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/Model.lean <<'EOF'\nimport Mathlib.Analysis.Calculus.Deriv.MeanValue\nimport Mathlib.Analysis.Calculus.Deriv.Mul\nimport Mathlib.Tactic\n\n/- Volume in litres, density in g/cm³, result in kg. -/\ndef waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000\ndef saltMoles : ℝ := 10 / 58.443\n/- Affine composition coordinate between Parker's measured molalities.\n   Affinity in composition is a modeling choice, not a consequence of two rows. -/\nnoncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)\n\n/- Apparent molar capacity, J/(mol K). Each rational temperature curve\n   is inferred from the 20,25,30 C calorimetry at one composition.\n   Extending these families to 19..100 C is an explicit empirical assumption. -/\nnoncomputable def apparentCapacity (t : ℝ) : ℝ :=\n  4.184 * ((1 - blend) * ((-13 * t - 2314) / (3 * t + 70)) +\n    blend * ((2 * t - 1275) / (t + 45)))\n\ndef netPower (W k t : ℝ) : ℝ := W - k * (t - 20)\n/- F,G are inverse first-law time primitives for water and brine. -/\nnoncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=\n  F x - F 20 + G B - G (z x)\n\n/- Identification, not hand-picked rational parameters: multiplying\n   y=(a*t+b)/(t+r) by its denominator gives a linear identification system.\n   These implications uniquely solve that system for both compositions. -/\nlemma calorimetric_identification :\n    ∀ a b r : ℝ,\n    (-19.8)*(20+r)=a*20+b → (-18.2)*(25+r)=a*25+b →\n    (-16.9)*(30+r)=a*30+b → a = -13/3 ∧ b = -2314/3 ∧ r = 70/3 := by\n  intros; constructor\n  · linarith\n  constructor <;> linarith\n\nlemma calorimetric_identification_upper :\n    ∀ a b r : ℝ,\n    (-19)*(20+r)=a*20+b → (-17.5)*(25+r)=a*25+b →\n    (-16.2)*(30+r)=a*30+b → a = 2 ∧ b = -1275 ∧ r = 45 := by\n  intros; constructor\n  · linarith\n  constructor <;> linarith\n\nlemma composition_inference :\n    waterMass = 0.99820675 ∧ 0 < saltMoles ∧ saltMoles < 0.18 ∧\n    0 ≤ blend ∧ blend ≤ 1 := by\n  norm_num [waterMass, saltMoles, blend]\n\n/- Rigorous bounds on the DECLARED rational family, not measured error bars.\n   Two chords bound the concave capacity curves from below. -/\nlemma capacity_bounds :\n    ∀ t : ℝ, t ∈ Set.Icc 19 100 →\n    -100 ≤ apparentCapacity t ∧ apparentCapacity t ≤ 0 ∧\n    (25 ≤ t → t ≤ 60 → -77 + (25/35)*(t-25) ≤ apparentCapacity t) ∧\n    (60 ≤ t → -52 + (11/40)*(t-60) ≤ apparentCapacity t) := by\n  intro t ht\n  obtain ⟨hm, hn, hnhi, hw, hw1⟩ := composition_inference\n  have hd : 0 < 3*t+70 := by linarith [ht.1]\n  have he : 0 < t+45 := by linarith [ht.1]\n  have hlo : -100/4.184 ≤ (-13*t-2314)/(3*t+70) := by\n    apply (le_div_iff₀ hd).2\n    nlinarith [ht.1]\n  have hup : -100/4.184 ≤ (2*t-1275)/(t+45) := by\n    apply (le_div_iff₀ he).2\n    nlinarith [ht.1]\n  have hln : (-13*t-2314)/(3*t+70) ≤ 0 :=\n    (div_nonpos_iff_of_pos_right hd).2 (by linarith [ht.1])\n  have hun : (2*t-1275)/(t+45) ≤ 0 :=\n    (div_nonpos_iff_of_pos_right he).2 (by linarith [ht.2])\n  have combine : ∀ l, l ≤ 4.184*((-13*t-2314)/(3*t+70)) →\n      l ≤ 4.184*((2*t-1275)/(t+45)) → l ≤ apparentCapacity t := by\n    intro l hl hu\n    unfold apparentCapacity\n    nlinarith [mul_nonneg (sub_nonneg.mpr hw1) (sub_nonneg.mpr hl),\n      mul_nonneg hw (sub_nonneg.mpr hu)]\n  refine ⟨combine (-100) (by nlinarith) (by nlinarith), ?_, ?_, ?_⟩\n  · unfold apparentCapacity\n    nlinarith [mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hw1) hln,\n      mul_nonpos_of_nonneg_of_nonpos hw hun]\n  · intro h25 h60\n    apply combine\n    · apply (le_div_iff₀ hd).1 at hlo\n      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)\n      have hb : (-77+(25/35)*(t-25))/4.184 ≤ (-13*t-2314)/(3*t+70) := by\n        apply (le_div_iff₀ hd).2\n        nlinarith\n      nlinarith\n    · have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)\n      have hb : (-77+(25/35)*(t-25))/4.184 ≤ (2*t-1275)/(t+45) := by\n        apply (le_div_iff₀ he).2\n        nlinarith\n      nlinarith\n  · intro h60\n    apply combine\n    · have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])\n      have hb : (-52+(11/40)*(t-60))/4.184 ≤ (-13*t-2314)/(3*t+70) := by\n        apply (le_div_iff₀ hd).2\n        nlinarith\n      nlinarith\n    · have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])\n      have hb : (-52+(11/40)*(t-60))/4.184 ≤ (2*t-1275)/(t+45) := by\n        apply (le_div_iff₀ he).2\n        nlinarith\n      nlinarith\n\n/- Differential comparison integrates an inequality without assuming\n   numerical quadrature or replacing a secant by a local heat capacity. -/\nlemma differential_comparison :\n    ∀ (f g : ℝ → ℝ) (df dg : ℝ → ℝ) (a b : ℝ), a ≤ b →\n    (∀ t ∈ Set.Icc a b, HasDerivAt f (df t) t) →\n    (∀ t ∈ Set.Icc a b, HasDerivAt g (dg t) t) →\n    (∀ t ∈ Set.Icc a b, dg t ≤ df t) →\n    g b - g a ≤ f b - f a := by\n  intro f g df dg a b hab hf hg hle\n  have hm : MonotoneOn (fun t => f t - g t) (Set.Icc a b) := by\n    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)\n    · intro t ht; exact ((hf t ht).sub (hg t ht)).continuousAt.continuousWithinAt\n    · intro t ht; exact ((hf t (interior_subset ht)).sub (hg t (interior_subset ht))).hasDerivWithinAt\n    · intro t ht; exact sub_nonneg.mpr (hle t (interior_subset ht))\n  have h := hm ⟨le_rfl,hab⟩ ⟨hab,le_rfl⟩ hab\n  linarith\n\n/- d is enthalpy of brine minus original water and stored 20 C solid,\n   per mole. I is solid sensible enthalpy 20->25 C. Positivity alone\n   suffices: no extrapolated solid Cp or numerical solid integral is used.\n   Parker anchor 928 cal/mol + affine finite-composition 87..88 cal/mol.\n   d'=absolute apparent capacity is Kirchhoff's law with fixed solid. -/\nlemma material_enthalpy_positive :\n    ∀ (d : ℝ → ℝ) (I : ℝ), 0 ≤ I →\n    d 25 = 4.184*(928+87+blend)+I →\n    (∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t) →\n    ∀ t ∈ Set.Icc 20 100, 100 < d t := by\n  intro d I hI ha hd t ht\n  have hanchor : 4246 ≤ d 25 := by\n    have hw := composition_inference.2.2.2.1\n    linarith\n  have hdec : ∀ a b : ℝ, 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a := by\n    intro a b hal hbh hab\n    have h := differential_comparison (fun x => -d x) (fun _ => 0)\n      (fun x => -apparentCapacity x) (fun _ => 0) a b hab\n      (by intro x hx; exact (hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩).neg)\n      (by intro x hx; exact hasDerivAt_const x 0)\n      (by intro x hx; exact neg_nonneg.mpr (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.1)\n    dsimp at h; linarith\n  have hfirst : d 25 - 2257.5 ≤ d 60 := by\n    have h := differential_comparison d\n      (fun x => -77*(x-25)+(25/70)*(x-25)\"'^2)\n      apparentCapacity (fun x => -77+(25/35)*(x-25)) 25 60 (by norm_num)\n      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)\n      (by intro x hx; convert ((hasDerivAt_id x).sub_const 25).const_mul (-77) |>.add\n            ((((hasDerivAt_id x).sub_const 25).pow 2).const_mul (25/70)) using 1 <;> ring)\n      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.1 hx.1 hx.2)\n    norm_num at h; linarith\n  have hsecond : d 60 - 1860 ≤ d 100 := by\n    have h := differential_comparison d\n      (fun x => -52*(x-60)+(11/80)*(x-60)''^2)\n      apparentCapacity (fun x => -52+(11/40)*(x-60)) 60 100 (by norm_num)\n      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)\n      (by intro x hx; convert ((hasDerivAt_id x).sub_const 60).const_mul (-52) |>.add\n            ((((hasDerivAt_id x).sub_const 60).pow 2).const_mul (11/80)) using 1 <;> ring)\n      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.2 hx.1)\n    norm_num at h; linarith\n  have hend := hdec t 100 (by linarith [ht.1]) le_rfl ht.2\n  linarith\nEOF\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle9/lean-01.txt 2>&1'"
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle9/lean-01.txt'"
}
shell output · exit 0
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle9/lean-01.txt'"
}
shell output · exit 0
/work/Model.lean:1:0: error: object file '/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic.olean' of module Mathlib.Tactic does not exist
shell input
{
  "command": "/usr/bin/bash -lc \"cat >> /work/Model.lean <<'EOF'\n\n/- Variable component storage, J/K: liquid-water specific Cp cw in\n   J/(kg K), plus nonnegative pot capacity p in J/K. -/\nnoncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=\n  waterMass * cw t + p t\n\n/- Scientific conclusion. All thermodynamic and first-law premises are\n   visible. z is the differentiable, liquid-valued mixing solution;\n   its existence/phase admissibility is an exposed physical guard.\n   No boiling dwell is allowed: addition x ends at pure-water onset B0.\n   The recommendation is conditional on the empirical rational family,\n   its composition interpolation and its full-temperature applicability. -/\ntheorem salt_timing_answer :\n    ∀ (U V cw p F G z : ℝ → ℝ) (K I W k B0 B x : ℝ),\n    0 ≤ I →\n    V 25 - U 25 - K = saltMoles * (4.184*(928+87+blend)+I) →\n    (∀ t ∈ Set.Icc 19 100, 4000 ≤ cw t ∧ 0 ≤ p t) →\n    (∀ t ∈ Set.Icc 19 100, HasDerivAt U (waterCapacity cw p t) t) →\n    (∀ t ∈ Set.Icc 19 100,\n      HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) →\n    20 ≤ B0 → B0 ≤ B → B ≤ 100 → 0 < k → k*(B-20) < W →\n    (∀ y, V (z y) = U y + K) →\n    (∀ y ∈ Set.Icc 20 B0, z y ∈ Set.Icc 19 B ∧ DifferentiableAt ℝ z y) →\n    (∀ t ∈ Set.Icc 19 B,\n      HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧\n      HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) /\n        netPower W k t) t) →\n    x ∈ Set.Icc 20 B0 →\n    z x < x ∧\n    netPower W k x < netPower W k (z x) ∧\n    totalTime F G z B 20 ≤ totalTime F G z B x := by\n  intro U V cw p F G z K I W k B0 B x hI ha hcomponents hU hV\n    hB0 hB0B hB hk hW hmix hz hFG hx\n  obtain ⟨hmass, hn, hnhi, hw, hw1⟩ := composition_inference\n  have hN : saltMoles ≠ 0 := ne_of_gt hn\n  have hstorage : ∀ t ∈ Set.Icc 19 100,\n      0 < waterCapacity cw p t ∧\n      0 < waterCapacity cw p t + saltMoles * apparentCapacity t := by\n    intro t ht\n    obtain ⟨hcw, hp⟩ := hcomponents t ht\n    have hcp := (capacity_bounds t ht).1\n    have hbound := mul_nonneg (le_of_lt hn) (show 0 ≤ apparentCapacity t + 100 by linarith)\n    unfold waterCapacity\n    rw [hmass]\n    constructor <;> nlinarith\n  have hd : ∀ t ∈ Set.Icc 20 100,\n      100 < (V t - U t - K) / saltMoles := by\n    apply material_enthalpy_positive (fun t => (V t-U t-K)/saltMoles) I hI\n    · rw [ha]; field_simp\n    · intro t ht\n      convert (((hV t ht).sub (hU t ht)).sub_const K).div_const saltMoles using 1\n      field_simp\n      ring\n  have hVm : StrictMonoOn V (Set.Icc 19 100) := by\n    apply strictMonoOn_of_hasDerivWithinAt_pos (convex_Icc _ _)\n    · intro t ht; exact (hV t ht).continuousAt.continuousWithinAt\n    · intro t ht; exact (hV t (interior_subset ht)).hasDerivWithinAt\n    · intro t ht; exact (hstorage t (interior_subset ht)).2\n  have hcool : ∀ y ∈ Set.Icc 20 B0, z y < y := by\n    intro y hy\n    have hy100 : y ∈ Set.Icc 19 100 := ⟨by linarith [hy.1],by linarith [hy.2]⟩\n    have hz100 : z y ∈ Set.Icc 19 100 := ⟨(hz y hy).1.1,by linarith [(hz y hy).1.2]⟩\n    have hdpos := (lt_div_iff₀ hn).1 (hd y ⟨hy.1,by linarith [hy.2]⟩)\n    by_contra h\n    have hle : V y ≤ V (z y) := hVm.monotoneOn hy100 hz100 (le_of_not_gt h)\n    rw [hmix y] at hle\n    nlinarith\n  have hpower : ∀ t ∈ Set.Icc 19 B, 0 < netPower W k t := by\n    intro t ht\n    unfold netPower\n    nlinarith [ht.2]\n  have hder : ∀ y ∈ Set.Icc 20 B0,\n      HasDerivAt (totalTime F G z B)\n        (waterCapacity cw p y *\n          (1 / netPower W k y - 1 / netPower W k (z y))) y := by\n    intro y hy\n    have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hy.1],by linarith [hy.2]⟩\n    have hy100 : y ∈ Set.Icc 19 100 := ⟨hyB.1,by linarith [hyB.2]⟩\n    have hzB := (hz y hy).1\n    have hz100 : z y ∈ Set.Icc 19 100 := ⟨hzB.1,by linarith [hzB.2]⟩\n    have hchain := (hV (z y) hz100).comp y (hz y hy).2.hasDerivAt\n    have hid : (fun t => V (z t)) = (fun t => U t + K) := funext hmix\n    change HasDerivAt (fun t => V (z t)) _ y at hchain\n    rw [hid] at hchain\n    have he := hchain.unique ((hU y hy100).add_const K)\n    have ht := (((hFG y hyB).1.sub_const (F 20)).add_const (G B)).sub\n      ((hFG (z y) hzB).2.comp y (hz y hy).2.hasDerivAt)\n    change HasDerivAt (totalTime F G z B) _ y at ht\n    convert ht using 1\n    have hny := ne_of_gt (hpower y hyB)\n    have hnz := ne_of_gt (hpower (z y) hzB)\n    field_simp [hny, hnz]\n    nlinarith [he]\n  have hmon : MonotoneOn (totalTime F G z B) (Set.Icc 20 B0) := by\n    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)\n    · intro y hy; exact (hder y hy).continuousAt.continuousWithinAt\n    · intro y hy; exact (hder y (interior_subset hy)).hasDerivWithinAt\n    · intro y hy\n      have hyI := interior_subset hy\n      have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hyI.1],by linarith [hyI.2]⟩\n      have hny := hpower y hyB\n      have hnz := hpower (z y) (hz y hyI).1\n      have horder : netPower W k y ≤ netPower W k (z y) := by\n        unfold netPower; nlinarith [hcool y hyI]\n      have hrecip : 1 / netPower W k (z y) ≤ 1 / netPower W k y :=\n        one_div_le_one_div_of_le hny horder\n      exact mul_nonneg (le_of_lt (hstorage y ⟨hyB.1,by linarith [hyB.2]⟩).1)\n        (sub_nonneg.mpr hrecip)\n  refine ⟨hcool x hx, ?_, hmon ⟨le_rfl,hB0⟩ hx hx.1⟩\n  unfold netPower\n  nlinarith [hcool x hx]\nEOF\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle9/lean-02.txt 2>&1\""
}
shell input
{
  "command": "/usr/bin/bash -lc 'ls /harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/*olean | head -40; ls /harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/*olean'"
}
shell output · exit 0
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Abel.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/AdaptationNote.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/AddGroup.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Algebraize.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ApplyAt.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ApplyCongr.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ApplyFun.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ApplyWith.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ArithMult.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Assume.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/BDSimp.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Basic.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Basify.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Bound.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ByCases.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ByContra.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/CancelDenoms.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Cases.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/CasesM.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Change.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Check.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Choose.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Clean.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ClearExcept.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ClearExclamation.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Clear_.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ClickSuggestions.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Coe.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Common.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ComputeDegree.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/CongrExclamation.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/CongrM.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Constructor.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Continuity.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/ContinuousFunctionalCalculus.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Contrapose.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Conv.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Convert.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/Core.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Tactic/CrossRefAttribute.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Add.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/AffineMap.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Basic.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Comp.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/CompMul.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Inv.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Inverse.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Linear.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/MeanValue.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Mul.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Pow.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Shift.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Slope.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/Support.olean
/harness/.lake/packages/mathlib/.lake/build/lib/lean/Mathlib/Analysis/Calculus/Deriv/ZPow.olean
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'\ns=open(p).read().replace('import Mathlib.Tactic\\\\n','import Mathlib.Tactic.Linarith\\\\nimport Mathlib.Tactic.FieldSimp\\\\nimport Mathlib.Tactic.Ring\\\\nimport Mathlib.Tactic.NormNum\\\\n')\nopen(p,'w').write(s)\nPY\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle9/lean-03.txt 2>&1\""
}
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle9/lean-03.txt'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle9/lean-03.txt'"
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"ps -eo pid,etime,args | grep '/opt/lean/bin/lean /work/Model'\""
}
shell output · exit 1 · failed
/usr/bin/bash: line 1: ps: command not found
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport os\nfor p in os.listdir('/proc'):\n if p.isdigit():\n  try:\n   cmd=open('/proc/'+p+'/cmdline','rb').read().replace(b'\\\\0',b' ').decode()\n   if '/opt/lean/bin/lean /work' in cmd:print(p,cmd[:140],open('/proc/'+p+'/stat').read().split()[13:17])\n  except:pass\nPY\""
}
shell output · exit 0
190 /usr/bin/bash -c python - <<'PY'
import os
for p in os.listdir('/proc'):
 if p.isdigit():
  try:
   cmd=open('/proc/'+p+'/cmdline','rb').rea ['0', '0', '0', '0']
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport os\nfor p in os.listdir('/proc'):\n if p.isdigit():\n  try:\n   cmd=open('/proc/'+p+'/cmdline','rb').read().replace(b'\\\\0',b' ').decode()\n   print(p,cmd[:180])\n  except:pass\nPY\""
}
shell output · exit 0
1 codex exec --model gpt-6.1-sol --config model_reasoning_effort="medium" --skip-git-repo-check --dangerously-bypass-approvals-and-sandbox --json - 
74 /usr/local/bin/codex-code-mode-host 
194 /usr/bin/bash -c python - <<'PY'
import os
for p in os.listdir('/proc'):
 if p.isdigit():
  try:
   cmd=open('/proc/'+p+'/cmdline','rb').read().replace(b'\0',b' ').decode()
   prin
195 python - 
assistant
The fitted rational curves reproduce the selected 20, 25 and 30 °C capacity values and allow the capacity change to vary with temperature. The proof will connect that change to the mixing temperature, derive the resulting change in heat loss, and compare total heating times. The main unresolved physical question is whether the fitted curves remain accurate up to boiling.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -l /opt/lean/bin/lean; cat /work/evidence/cycle9/lean-03.txt; ls -l /work/evidence/cycle9'"
}
shell output · exit 0
-rwxr-xr-x 1 1001 1001 9024 Oct 12 16:41 /opt/lean/bin/lean
/work/Model.lean:9:4: error(lean.dependsOnNoncomputable): failed to compile definition, consider marking it as 'noncomputable' because it depends on 'Real.instDivInvMonoid', which is 'noncomputable'
/work/Model.lean:10:4: error(lean.dependsOnNoncomputable): failed to compile definition, consider marking it as 'noncomputable' because it depends on 'Real.instDivInvMonoid', which is 'noncomputable'
/work/Model.lean:69:5: error(lean.unknownIdentifier): Unknown identifier `div_nonpos_iff_of_pos_right`
/work/Model.lean:71:5: error(lean.unknownIdentifier): Unknown identifier `div_nonpos_iff_of_pos_right`
/work/Model.lean:88:8: error: linarith failed to find a contradiction
t : ℝ
ht : t ∈ Set.Icc 19 100
hm : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hd : 0 < 3 * t + 70
he : 0 < t + 45
hup : -100 / 4.184 ≤ (2 * t - 1275) / (t + 45)
hln : (-13 * t - 2314) / (3 * t + 70) ≤ 0
hun : (2 * t - 1275) / (t + 45) ≤ 0
combine :
  ∀ l ≤ 4.184 * ((-13 * t - 2314) / (3 * t + 70)), l ≤ 4.184 * ((2 * t - 1275) / (t + 45)) → l ≤ apparentCapacity t
h25 : 25 ≤ t
h60 : t ≤ 60
hlo : -100 / 4.184 * (3 * t + 70) ≤ -13 * t - 2314
hprod : 0 ≤ (t - 25) * (60 - t)
a✝ : -13 * t - 2314 < (-77 + 25 / 35 * (t - 25)) / 4.184 * (3 * t + 70)
⊢ False
failed
/work/Model.lean:89:6: error: linarith failed to find a contradiction
case refine_2.a
t : ℝ
ht : t ∈ Set.Icc 19 100
hm : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hd : 0 < 3 * t + 70
he : 0 < t + 45
hup : -100 / 4.184 ≤ (2 * t - 1275) / (t + 45)
hln : (-13 * t - 2314) / (3 * t + 70) ≤ 0
hun : (2 * t - 1275) / (t + 45) ≤ 0
combine :
  ∀ l ≤ 4.184 * ((-13 * t - 2314) / (3 * t + 70)), l ≤ 4.184 * ((2 * t - 1275) / (t + 45)) → l ≤ apparentCapacity t
h25 : 25 ≤ t
h60 : t ≤ 60
hlo : -100 / 4.184 * (3 * t + 70) ≤ -13 * t - 2314
hprod : 0 ≤ (t - 25) * (60 - t)
hb : (-77 + 25 / 35 * (t - 25)) / 4.184 ≤ (-13 * t - 2314) / (3 * t + 70)
a✝ : 4.184 * ((-13 * t - 2314) / (3 * t + 70)) < -77 + 25 / 35 * (t - 25)
⊢ False
failed
/work/Model.lean:93:8: error: linarith failed to find a contradiction
t : ℝ
ht : t ∈ Set.Icc 19 100
hm : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hd : 0 < 3 * t + 70
he : 0 < t + 45
hlo : -100 / 4.184 ≤ (-13 * t - 2314) / (3 * t + 70)
hup : -100 / 4.184 ≤ (2 * t - 1275) / (t + 45)
hln : (-13 * t - 2314) / (3 * t + 70) ≤ 0
hun : (2 * t - 1275) / (t + 45) ≤ 0
combine :
  ∀ l ≤ 4.184 * ((-13 * t - 2314) / (3 * t + 70)), l ≤ 4.184 * ((2 * t - 1275) / (t + 45)) → l ≤ apparentCapacity t
h25 : 25 ≤ t
h60 : t ≤ 60
hprod : 0 ≤ (t - 25) * (60 - t)
a✝ : 2 * t - 1275 < (-77 + 25 / 35 * (t - 25)) / 4.184 * (t + 45)
⊢ False
failed
/work/Model.lean:94:6: error: linarith failed to find a contradiction
case refine_2.a
t : ℝ
ht : t ∈ Set.Icc 19 100
hm : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hd : 0 < 3 * t + 70
he : 0 < t + 45
hlo : -100 / 4.184 ≤ (-13 * t - 2314) / (3 * t + 70)
hup : -100 / 4.184 ≤ (2 * t - 1275) / (t + 45)
hln : (-13 * t - 2314) / (3 * t + 70) ≤ 0
hun : (2 * t - 1275) / (t + 45) ≤ 0
combine :
  ∀ l ≤ 4.184 * ((-13 * t - 2314) / (3 * t + 70)), l ≤ 4.184 * ((2 * t - 1275) / (t + 45)) → l ≤ apparentCapacity t
h25 : 25 ≤ t
h60 : t ≤ 60
hprod : 0 ≤ (t - 25) * (60 - t)
hb : (-77 + 25 / 35 * (t - 25)) / 4.184 ≤ (2 * t - 1275) / (t + 45)
a✝ : 4.184 * ((2 * t - 1275) / (t + 45)) < -77 + 25 / 35 * (t - 25)
⊢ False
failed
/work/Model.lean:100:8: error: linarith failed to find a contradiction
t : ℝ
ht : t ∈ Set.Icc 19 100
hm : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hd : 0 < 3 * t + 70
he : 0 < t + 45
hlo : -100 / 4.184 ≤ (-13 * t - 2314) / (3 * t + 70)
hup : -100 / 4.184 ≤ (2 * t - 1275) / (t + 45)
hln : (-13 * t - 2314) / (3 * t + 70) ≤ 0
hun : (2 * t - 1275) / (t + 45) ≤ 0
combine :
  ∀ l ≤ 4.184 * ((-13 * t - 2314) / (3 * t + 70)), l ≤ 4.184 * ((2 * t - 1275) / (t + 45)) → l ≤ apparentCapacity t
h60 : 60 ≤ t
hprod : 0 ≤ (t - 60) * (100 - t)
a✝ : -13 * t - 2314 < (-52 + 11 / 40 * (t - 60)) / 4.184 * (3 * t + 70)
⊢ False
failed
/work/Model.lean:101:6: error: linarith failed to find a contradiction
case refine_3.a
t : ℝ
ht : t ∈ Set.Icc 19 100
hm : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hd : 0 < 3 * t + 70
he : 0 < t + 45
hlo : -100 / 4.184 ≤ (-13 * t - 2314) / (3 * t + 70)
hup : -100 / 4.184 ≤ (2 * t - 1275) / (t + 45)
hln : (-13 * t - 2314) / (3 * t + 70) ≤ 0
hun : (2 * t - 1275) / (t + 45) ≤ 0
combine :
  ∀ l ≤ 4.184 * ((-13 * t - 2314) / (3 * t + 70)), l ≤ 4.184 * ((2 * t - 1275) / (t + 45)) → l ≤ apparentCapacity t
h60 : 60 ≤ t
hprod : 0 ≤ (t - 60) * (100 - t)
hb : (-52 + 11 / 40 * (t - 60)) / 4.184 ≤ (-13 * t - 2314) / (3 * t + 70)
a✝ : 4.184 * ((-13 * t - 2314) / (3 * t + 70)) < -52 + 11 / 40 * (t - 60)
⊢ False
failed
/work/Model.lean:105:8: error: linarith failed to find a contradiction
t : ℝ
ht : t ∈ Set.Icc 19 100
hm : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hd : 0 < 3 * t + 70
he : 0 < t + 45
hlo : -100 / 4.184 ≤ (-13 * t - 2314) / (3 * t + 70)
hup : -100 / 4.184 ≤ (2 * t - 1275) / (t + 45)
hln : (-13 * t - 2314) / (3 * t + 70) ≤ 0
hun : (2 * t - 1275) / (t + 45) ≤ 0
combine :
  ∀ l ≤ 4.184 * ((-13 * t - 2314) / (3 * t + 70)), l ≤ 4.184 * ((2 * t - 1275) / (t + 45)) → l ≤ apparentCapacity t
h60 : 60 ≤ t
hprod : 0 ≤ (t - 60) * (100 - t)
a✝ : 2 * t - 1275 < (-52 + 11 / 40 * (t - 60)) / 4.184 * (t + 45)
⊢ False
failed
/work/Model.lean:106:6: error: linarith failed to find a contradiction
case refine_3.a
t : ℝ
ht : t ∈ Set.Icc 19 100
hm : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hd : 0 < 3 * t + 70
he : 0 < t + 45
hlo : -100 / 4.184 ≤ (-13 * t - 2314) / (3 * t + 70)
hup : -100 / 4.184 ≤ (2 * t - 1275) / (t + 45)
hln : (-13 * t - 2314) / (3 * t + 70) ≤ 0
hun : (2 * t - 1275) / (t + 45) ≤ 0
combine :
  ∀ l ≤ 4.184 * ((-13 * t - 2314) / (3 * t + 70)), l ≤ 4.184 * ((2 * t - 1275) / (t + 45)) → l ≤ apparentCapacity t
h60 : 60 ≤ t
hprod : 0 ≤ (t - 60) * (100 - t)
hb : (-52 + 11 / 40 * (t - 60)) / 4.184 ≤ (2 * t - 1275) / (t + 45)
a✝ : 4.184 * ((2 * t - 1275) / (t + 45)) < -52 + 11 / 40 * (t - 60)
⊢ False
failed
/work/Model.lean:146:4: error: `dsimp` made no progress
/work/Model.lean:153:47: error(lean.invalidField): Invalid field `pow`: The environment does not contain `HasFDerivAtFilter.pow`, so it is not possible to project the field `pow` from an expression
  HasDerivAt.sub_const 25 (hasDerivAt_id x)
of type
  HasFDerivAtFilter (fun x => id x - 25) (ContinuousLinearMap.toSpanSingleton ℝ 1) (nhds x ×ˢ pure x)
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
/work/Model.lean:152:7: error: unsolved goals
case e'_8
d : ℝ → ℝ
I : ℝ
hI : 0 ≤ I
ha : d 25 = 4.184 * (928 + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4246 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
x : ℝ
hx : x ∈ Set.Icc 25 60
⊢ (fun x => 30075 / 14 + x * (-664 / 7) + x ^ 2 * (5 / 14)) = (fun y => 1925 - id y * 77) * 2

case e'_9
d : ℝ → ℝ
I : ℝ
hI : 0 ≤ I
ha : d 25 = 4.184 * (928 + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4246 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
x : ℝ
hx : x ∈ Set.Icc 25 60
⊢ -664 / 7 + x * (5 / 7) = -77 + x
/work/Model.lean:162:47: error(lean.invalidField): Invalid field `pow`: The environment does not contain `HasFDerivAtFilter.pow`, so it is not possible to project the field `pow` from an expression
  HasDerivAt.sub_const 60 (hasDerivAt_id x)
of type
  HasFDerivAtFilter (fun x => id x - 60) (ContinuousLinearMap.toSpanSingleton ℝ 1) (nhds x ×ˢ pure x)
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
/work/Model.lean:161:7: error: unsolved goals
case e'_8
d : ℝ → ℝ
I : ℝ
hI : 0 ≤ I
ha : d 25 = 4.184 * (928 + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4246 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
hfirst : d 25 - 2257.5 ≤ d 60
x : ℝ
hx : x ∈ Set.Icc 60 100
⊢ (fun x => 3615 + x * (-137 / 2) + x ^ 2 * (11 / 80)) = (fun y => 3120 - id y * 52) * 2

case e'_9
d : ℝ → ℝ
I : ℝ
hI : 0 ≤ I
ha : d 25 = 4.184 * (928 + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4246 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
hfirst : d 25 - 2257.5 ≤ d 60
x : ℝ
hx : x ∈ Set.Icc 60 100
⊢ -137 / 2 + x * (11 / 40) = -52 + x
/work/Model.lean:259:4: error: linarith failed to find a contradiction
case h1
U V cw p F G z : ℝ → ℝ
K I W k B0 B x : ℝ
hI : 0 ≤ I
ha : V 25 - U 25 - K = saltMoles * (4.184 * (928 + 87 + blend) + I)
hcomponents : ∀ t ∈ Set.Icc 19 100, 4000 ≤ cw t ∧ 0 ≤ p t
hU : ∀ t ∈ Set.Icc 19 100, HasDerivAt U (waterCapacity cw p t) t
hV : ∀ t ∈ Set.Icc 19 100, HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t
hB0 : 20 ≤ B0
hB0B : B0 ≤ B
hB : B ≤ 100
hk : 0 < k
hW : k * (B - 20) < W
hmix : ∀ (y : ℝ), V (z y) = U y + K
hz : ∀ y ∈ Set.Icc 20 B0, z y ∈ Set.Icc 19 B ∧ DifferentiableAt ℝ z y
hFG :
  ∀ t ∈ Set.Icc 19 B,
    HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
      HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t
hx : x ∈ Set.Icc 20 B0
hmass : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hN : saltMoles ≠ 0
hstorage : ∀ t ∈ Set.Icc 19 100, 0 < waterCapacity cw p t ∧ 0 < waterCapacity cw p t + saltMoles * apparentCapacity t
hd : ∀ t ∈ Set.Icc 20 100, 100 < (V t - U t - K) / saltMoles
hVm : StrictMonoOn V (Set.Icc 19 100)
hcool : ∀ y ∈ Set.Icc 20 B0, z y < y
hpower : ∀ t ∈ Set.Icc 19 B, 0 < netPower W k t
y : ℝ
hy : y ∈ Set.Icc 20 B0
hyB : y ∈ Set.Icc 19 B
hy100 : y ∈ Set.Icc 19 100
hzB : z y ∈ Set.Icc 19 B
hz100 : z y ∈ Set.Icc 19 100
hid : (fun t => V (z t)) = fun t => U t + K
hchain : HasDerivAt (fun t => U t + K) ((waterCapacity cw p (z y) + saltMoles * apparentCapacity (z y)) * deriv z y) y
he : (waterCapacity cw p (z y) + saltMoles * apparentCapacity (z y)) * deriv z y = waterCapacity cw p y
ht :
  HasDerivAt (totalTime F G z B)
    (waterCapacity cw p y / netPower W k y -
      (waterCapacity cw p (z y) + saltMoles * apparentCapacity (z y)) / netPower W k (z y) * deriv z y)
    y
hny : netPower W k y ≠ 0
hnz : netPower W k (z y) ≠ 0
a✝ :
  waterCapacity cw p y * (netPower W k (z y) - netPower W k y) <
    waterCapacity cw p y * netPower W k (z y) -
      netPower W k y * (waterCapacity cw p (z y) + saltMoles * apparentCapacity (z y)) * deriv z y
⊢ False
failed
total 24
-rw-r--r-- 1 1001 1001   157 Nov 18 02:22 lean-01.txt
-rw-r--r-- 1 1001 1001   157 Nov 18 02:23 lean-02.txt
-rw-r--r-- 1 1001 1001 12566 Nov 18 02:24 lean-03.txt
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'\ns=open(p).read().replace('import Mathlib.Analysis.Calculus.Deriv.Mul','import Mathlib.Analysis.Calculus.Deriv.Mul\\\\nimport Mathlib.Analysis.Calculus.Deriv.Pow')\ns=s.replace('def waterMass','noncomputable def waterMass').replace('def saltMoles','noncomputable def saltMoles')\ns=s.replace('(div_nonpos_iff_of_pos_right hd).2 (by linarith [ht.1])','div_nonpos_of_nonpos_of_nonneg (by linarith [ht.1]) (le_of_lt hd)').replace('(div_nonpos_iff_of_pos_right he).2 (by linarith [ht.2])','div_nonpos_of_nonpos_of_nonneg (by linarith [ht.2]) (le_of_lt he)')\n# Replace capacity chord proof blocks\nstart=s.index('  · intro h25 h60')\nend=s.index('\\\\n/- Differential comparison',start)\ns=s[:start]+'''  · intro h25 h60\n    apply combine\n    · rw [← mul_div_assoc]\n      apply (le_div_iff₀ hd).2\n      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)\n      norm_num at *\n      nlinarith\n    · rw [← mul_div_assoc]\n      apply (le_div_iff₀ he).2\n      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)\n      norm_num at *\n      nlinarith\n  · intro h60\n    apply combine\n    · rw [← mul_div_assoc]\n      apply (le_div_iff₀ hd).2\n      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])\n      norm_num at *\n      nlinarith\n    · rw [← mul_div_assoc]\n      apply (le_div_iff₀ he).2\n      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])\n      norm_num at *\n      nlinarith\n''' +s[end:]\ns=s.replace('''    field_simp [hny, hnz]\n    nlinarith [he]''','''    field_simp [hny, hnz]\n    have he' := congrArg (fun a : ℝ => netPower W k y * a) he\n    nlinarith only [he']''')\nopen(p,'w').write(s)\nPY\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle9/lean-04.txt 2>&1\""
}
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle9/lean-04.txt'"
}
shell output · exit 0
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'\ns=open(p).read()\nstart=s.index('/- Apparent molar capacity')\nend=s.index('\\\\ndef netPower',start)\ns=s[:start]+'''/- Rational family (a*t+b)/(t+r), identified from three calorimetric\n   values. First differences determine r; two equations then give a,b.\n   This is an empirical family choice, not a claimed law of electrolytes. -/\nnoncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=\n  let d1 := y25-y20\n  let d2 := y30-y25\n  let r := (30*d2-20*d1)/(d1-d2)\n  let a := (y25*(25+r)-y20*(20+r))/5\n  let b := y20*(20+r)-20*a\n  (a*t+b)/(t+r)\n\n/- Apparent molar capacity J/(mol K), fitted to Parker table II C.\n   Affine composition interpolation and extension to 19..100 C are\n   independent empirical choices, not certified consequences of the data. -/\nnoncomputable def apparentCapacity (t : ℝ) : ℝ :=\n  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +\n    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)\n\nlemma capacity_formula : ∀ t : ℝ,\n    apparentCapacity t =\n      4.184*((1-blend)*((-13*t-2314)/(3*t+70)) +\n        blend*((2*t-1275)/(t+45))) := by\n  intro t\n  unfold apparentCapacity calorimetricCurve\n  norm_num\n  congr 2\n  congr 1\n  field_simp\n  <;> ring\n''' +s[end:]\n# Add formula rewrite inside capacity_bounds, changing combine unfolding\ns=s.replace('''    unfold apparentCapacity\n    nlinarith''','''    rw [capacity_formula]\n    nlinarith''')\ns=s.replace('''  · unfold apparentCapacity\n    nlinarith''','''  · rw [capacity_formula]\n    nlinarith''')\n# Include source uncertainty in anchor\ns=s.replace('(d : ℝ → ℝ) (I : ℝ), 0 ≤ I →','(d : ℝ → ℝ) (I H : ℝ), 0 ≤ I → 923 ≤ H →')\ns=s.replace('d 25 = 4.184*(928+87+blend)+I','d 25 = 4.184*(H+87+blend)+I')\ns=s.replace('intro d I hI ha hd t ht','intro d I H hI hH ha hd t ht')\ns=s.replace('4246 ≤ d 25','4225 ≤ d 25')\ns=s.replace('(K I W k B0 B x : ℝ),\\\\n    0 ≤ I →','(K I H W k B0 B x : ℝ),\\\\n    0 ≤ I → 923 ≤ H → H ≤ 933 →')\ns=s.replace('saltMoles * (4.184*(928+87+blend)+I)','saltMoles * (4.184*(H+87+blend)+I)')\ns=s.replace('intro U V cw p F G z K I W k B0 B x hI ha hcomponents hU hV','intro U V cw p F G z K I H W k B0 B x hI hH hHhi ha hcomponents hU hV')\ns=s.replace(') I hI\\\\n',') I H hI hH\\\\n')\nopen(p,'w').write(s)\nPY\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle9/lean-05.txt 2>&1\""
}
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle9/lean-04.txt; cat /work/evidence/cycle9/lean-05.txt'"
}
shell output · exit 0
/work/Model.lean:146:4: error: `dsimp` made no progress
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
/work/Model.lean:152:7: error: unsolved goals
case e'_8
d : ℝ → ℝ
I : ℝ
hI : 0 ≤ I
ha : d 25 = 4.184 * (928 + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4246 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
x : ℝ
hx : x ∈ Set.Icc 25 60
⊢ (fun x => 30075 / 14 + x * (-664 / 7) + x ^ 2 * (5 / 14)) =
    (fun y => 1925 - id y * 77) + fun y => ((fun x => -25 + id x) ^ 2) y * (5 / 14)

case e'_9
d : ℝ → ℝ
I : ℝ
hI : 0 ≤ I
ha : d 25 = 4.184 * (928 + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4246 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
x : ℝ
hx : x ∈ Set.Icc 25 60
⊢ -664 / 7 + x * (5 / 7) = -664 / 7 + id x * (5 / 7)
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
/work/Model.lean:161:7: error: unsolved goals
case e'_8
d : ℝ → ℝ
I : ℝ
hI : 0 ≤ I
ha : d 25 = 4.184 * (928 + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4246 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
hfirst : d 25 - 2257.5 ≤ d 60
x : ℝ
hx : x ∈ Set.Icc 60 100
⊢ (fun x => 3615 + x * (-137 / 2) + x ^ 2 * (11 / 80)) =
    (fun y => 3120 - id y * 52) + fun y => ((fun x => -60 + id x) ^ 2) y * (11 / 80)

case e'_9
d : ℝ → ℝ
I : ℝ
hI : 0 ≤ I
ha : d 25 = 4.184 * (928 + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4246 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
hfirst : d 25 - 2257.5 ≤ d 60
x : ℝ
hx : x ∈ Set.Icc 60 100
⊢ -137 / 2 + x * (11 / 40) = -137 / 2 + id x * (11 / 40)
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
/work/Model.lean:37:38: error: unsolved goals
case e_a.e_a.e_a
t : ℝ
⊢ -2314 - t * 13 = -6942 - t * 39

case e_a.e_a.e_a
t : ℝ
⊢ t + 70 / 3 = 3 * t + 70
/work/Model.lean:169:4: error: `dsimp` made no progress
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
/work/Model.lean:175:7: error: unsolved goals
case e'_8
d : ℝ → ℝ
I H : ℝ
hI : 0 ≤ I
hH : 923 ≤ H
ha : d 25 = 4.184 * (H + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4225 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
x : ℝ
hx : x ∈ Set.Icc 25 60
⊢ (fun x => 30075 / 14 + x * (-664 / 7) + x ^ 2 * (5 / 14)) =
    (fun y => 1925 - id y * 77) + fun y => ((fun x => -25 + id x) ^ 2) y * (5 / 14)

case e'_9
d : ℝ → ℝ
I H : ℝ
hI : 0 ≤ I
hH : 923 ≤ H
ha : d 25 = 4.184 * (H + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4225 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
x : ℝ
hx : x ∈ Set.Icc 25 60
⊢ -664 / 7 + x * (5 / 7) = -664 / 7 + id x * (5 / 7)
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
Try this:
  [apply] ring_nf
  
  The `ring` tactic failed to close the goal. Use `ring_nf` to obtain a normal form.
    
  Note that `ring` works primarily in *commutative* rings. If you have a noncommutative ring, abelian group or module, consider using `noncomm_ring`, `abel` or `module` instead.
/work/Model.lean:184:7: error: unsolved goals
case e'_8
d : ℝ → ℝ
I H : ℝ
hI : 0 ≤ I
hH : 923 ≤ H
ha : d 25 = 4.184 * (H + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4225 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
hfirst : d 25 - 2257.5 ≤ d 60
x : ℝ
hx : x ∈ Set.Icc 60 100
⊢ (fun x => 3615 + x * (-137 / 2) + x ^ 2 * (11 / 80)) =
    (fun y => 3120 - id y * 52) + fun y => ((fun x => -60 + id x) ^ 2) y * (11 / 80)

case e'_9
d : ℝ → ℝ
I H : ℝ
hI : 0 ≤ I
hH : 923 ≤ H
ha : d 25 = 4.184 * (H + 87 + blend) + I
hd : ∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t
t : ℝ
ht : t ∈ Set.Icc 20 100
hanchor : 4225 ≤ d 25
hdec : ∀ (a b : ℝ), 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a
hfirst : d 25 - 2257.5 ≤ d 60
x : ℝ
hx : x ∈ Set.Icc 60 100
⊢ -137 / 2 + x * (11 / 40) = -137 / 2 + id x * (11 / 40)
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'\ns=open(p).read().replace('''  congr 2\n  congr 1\n  field_simp\n  <;> ring''','''  have hratio : ((-13/3)*t + (-2314/3))/(t+70/3) =\n      (-13*t-2314)/(3*t+70) := by\n    field_simp\n    <;> ring\n  rw [hratio]''')\ns=s.replace('    dsimp at h; linarith','    linarith')\ns=s.replace('using 1 <;> ring)\\\\n      (by intro x hx;', '''using 1\n          · ext v; simp; ring\n          · dsimp; ring)\n      (by intro x hx;''')\nopen(p,'w').write(s)\nPY\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle9/lean-06.txt 2>&1\""
}
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle9/lean-06.txt'"
}
shell output · exit 0
/work/Model.lean:45:6: error: Tactic `rewrite` failed: Did not find an occurrence of the pattern
  (-13 / 3 * t + -2314 / 3) / (t + 70 / 3)
in the target expression
  (1 - blend) * ((-(13 / 3 * t) + -(2314 / 3)) / (t + 70 / 3)) + blend * ((2 * t + -1275) / (t + 45)) =
    (1 - blend) * ((-(13 * t) - 2314) / (3 * t + 70)) + blend * ((2 * t - 1275) / (t + 45))

t : ℝ
hratio : (-13 / 3 * t + -2314 / 3) / (t + 70 / 3) = (-13 * t - 2314) / (3 * t + 70)
⊢ (1 - blend) * ((-(13 / 3 * t) + -(2314 / 3)) / (t + 70 / 3)) + blend * ((2 * t + -1275) / (t + 45)) =
    (1 - blend) * ((-(13 * t) - 2314) / (3 * t + 70)) + blend * ((2 * t - 1275) / (t + 45))
/work/Model.lean:178:25: error: No goals to be solved
/work/Model.lean:189:25: error: No goals to be solved
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean'\ns=open(p).read().replace('have hratio : ((-13/3)*t + (-2314/3))/(t+70/3) =\\\\n      (-13*t-2314)/(3*t+70)', 'have hratio : (-(13/3*t) + -(2314/3))/(t+70/3) =\\\\n      (-(13*t)-2314)/(3*t+70)')\ns=s.replace('  rw [hratio]\\\\n','  rw [hratio]\\\\n  ring\\\\n')\ns=s.replace('ext v; simp; ring','ext v; simp <;> ring')\nopen(p,'w').write(s)\nPY\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/Model.lean > /work/evidence/cycle9/lean-07.txt 2>&1\""
}
shell output · exit 0
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nfrom pathlib import Path\np=Path('/work/Model.lean');s=p.read_text()\npos=s.index('/- Variable component storage')\ns=s[:pos]+'''/- The shared loss law derives a power change from the mixing jump;\n   no independent before/after heating powers are introduced. -/\nlemma newtonian_power_change : ∀ W k x z : ℝ,\n    netPower W k z - netPower W k x = k*(x-z) := by\n  intro W k x z\n  unfold netPower\n  ring\n\n'''+s[pos:]\ns=s.replace('''    z x < x ∧\n    netPower W k x < netPower W k (z x) ∧''','''    z x < x ∧\n    netPower W k (z x) - netPower W k x = k*(x-z x) ∧\n    netPower W k x < netPower W k (z x) ∧''')\ns=s.replace('''  refine ⟨hcool x hx, ?_, hmon ⟨le_rfl,hB0⟩ hx hx.1⟩''','''  refine ⟨hcool x hx, newtonian_power_change W k x (z x), ?_,\n    hmon ⟨le_rfl,hB0⟩ hx hx.1⟩''')\np.write_text(s)\nPY\ncat /work/evidence/cycle9/lean-07.txt\""
}
shell output · exit 0
/work/Model.lean:44:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:44:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/Model.lean:179:24: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:179:28: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:190:24: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:190:28: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/Model.lean:179:28: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
/work/Model.lean:190:28: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
assistant
The variable-capacity timing proof now compiles locally. Within the declared model, it derives a positive mixing-energy difference throughout 20–100 °C and shows that immediate addition minimizes boiling time when the shared Newtonian heat-loss coefficient is positive. I’m preparing the review packet, with the extrapolation and liquid-state assumptions clearly separated from the proved consequences, then running the required harness check.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport json,math\nfrom pathlib import Path\nmwater=1*1000*.99820675/1000;n=10/58.443;m=n/mwater;w=(m-.1388)/(.185-.1388)\ndef fit(y20,y25,y30):\n d1=y25-y20;d2=y30-y25;r=(30*d2-20*d1)/(d1-d2);a=(y25*(25+r)-y20*(20+r))/5;b=y20*(20+r)-20*a\n return a,b,r\ndef cpcurve(c,t):\n a,b,r=c;return (a*t+b)/(t+r)\nl=fit(-19.8,-18.2,-16.9);u=fit(-19,-17.5,-16.2)\ndata={'kind':'synthetic exact-family diagnostics; not measurements, not interval certificate','mass_kg':mwater,'n_mol':n,'m_mol_per_kg':m,'blend':w,'lower_fit_a_b_r':l,'upper_fit_a_b_r':u,'capacity_J_per_mol_K':{str(t):4.184*((1-w)*cpcurve(l,t)+w*cpcurve(u,t)) for t in[19,20,25,30,60,100]},'held_out_15C_cal_residuals':[cpcurve(l,15)-(-21.4),cpcurve(u,15)-(-20.5)],'proved_coarse_enthalpy_lower_J_per_mol':4225-2257.5-1860}\nPath('/work/evidence/cycle9/family-diagnostics.json').write_text(json.dumps(data,indent=2))\nprint(json.dumps(data,indent=2))\nPY\""
}
shell output · exit 0
{
  "kind": "synthetic exact-family diagnostics; not measurements, not interval certificate",
  "mass_kg": 0.99820675,
  "n_mol": 0.1711068904744794,
  "m_mol_per_kg": 0.17141427913053023,
  "blend": 0.7059367777171045,
  "lower_fit_a_b_r": [
    -4.333333333333348,
    -771.3333333333316,
    23.333333333333254
  ],
  "upper_fit_a_b_r": [
    2.000000000000091,
    -1275.000000000007,
    45.00000000000027
  ],
  "capacity_J_per_mol_K": {
    "19": -81.89896891639091,
    "20": -80.48028841762532,
    "25": -74.08125236542215,
    "30": -68.64205236542215,
    "60": -47.7169760783155,
    "100": -33.91530152324606
  },
  "held_out_15C_cal_residuals": [
    -0.4173913043478308,
    -0.25
  ],
  "proved_coarse_enthalpy_lower_J_per_mol": 107.5
}
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/report.txt <<'EOF'\nThe original information does not specify a universal addition temperature or a heating time. Salt identity and quantity, thermal storage, heat input and losses are missing. The revised result is conditional: for the retained 10 g dry NaCl / 1 litre / 20 C scenario, the explicitly calibrated material model below and the common Newtonian heat-loss model imply that adding immediately at 20 C minimizes time to brine boiling. No number of seconds or measured saving is inferred. This is an illustrative empirical-model result, not a certified full-temperature material-property prediction or human acceptance.\n\nSupplied information and lineage.\nThe user supplied one litre of initially 20 C water, a pot and stove already heating, and the intention to add salt. Salt amount, identity and apparatus were unspecified. All subsequent material specifications are scenario choices. Prior attempts and raw check errors are retained in history and checks. The previously checked affine-capacity candidate was rejected by human review. It is archived in history/cycle9-start and is not endorsed here.\n\nResponses f7c987a52391410bb035542305825b3f and 8ee08d44180740abb377ff631b6f1452 supplied primary literature, including Parker's tables. Response 385ae674960d48e49d45526c2703465f supplied a diagnostic corrected-Archer/Pytzer + AW90 + IAPWS95 variant, explicitly different from original Archer/Hill. Response e619fbb0992b47fab14c4641bd0dcbf2 records failed interval certification and clarifies that a tractable declared empirical representation and conditional conclusion are allowed. No interval enclosure, experiment or full-temperature physical error bound was supplied. The current candidate changes representation explicitly to a Parker-calibrated rational family. It does not silently reuse the diagnostic variant, the rejected secant capacity, Partanen coefficient interpolation, dissolution-enthalpy extrapolation, or a constant solid Cp. No outside agent or paid service was used.\n\nScenario and calibration observations.\nChoose 10 g pure crystalline NaCl stored at 20 C, ambient and initial pot at 20 C, pressure 0.100 MPa, no evaporation or mass loss, complete instantaneous adiabatic dissolution, and a common lumped pot/liquid temperature. Neglect small pressure corrections between the calorimetric reference and the chosen pressure. The water-density reference is air-free water at 20 C; actual volume/purity/temperature uncertainty is not supplied.\n\nwaterMass = (1 L)(1000 cm\"'^3/L)(0.99820675 g/cm''^3)(1 kg/1000 g) = 0.99820675 kg.\nsaltMoles = 10 g / (58.443 g/mol).\nThus m = saltMoles/waterMass = approximately 0.1714142791 mol/kg, inside the two Parker rows. The exact conversions and the interpolation weight w=(m-0.1388)/(0.1850-0.1388) in [0,1] are proved, not independent numerical premises. The reference density itself is the published NIST tabular value, not an independently proved evaluation of the density EOS.\n\nParker (1965), printed p43, Table II C gives ABSOLUTE apparent molar capacities in thermochemical cal/(mol K):\n m=0.1388: -19.8 at20 C, -18.2 at25 C, -16.9 at30 C;\n m=0.1850: -19.0 at20 C, -17.5 at25 C, -16.2 at30 C.\nPrinted p50, Table X gives RELATIVE apparent molar enthalpy at25 C: 87 and88 cal/mol at those same compositions. Printed p26 gives standard infinite-dilution solid dissolution enthalpy at25 C, +928 +/-5 cal/mol. We expose H in [923,933] cal/mol as an empirical input interval motivated by that quoted uncertainty, not a statistical coverage guarantee. The table capacities and finite-concentration values are treated as nominal calibration inputs. 1 thermochemical cal = 4.184 J. I visually inspected all three original-page PNGs in this cycle, rather than relying only on the CSV transcriptions.\n\nAdditional empirical material family, and what is actually inferred.\nAt each bounding composition choose C_app(t)=(a*t+b)/(t+r) in cal/(mol K). This is a three-parameter rational empirical approximant. It accommodates the observed positive, diminishing temperature increments without imposing constant capacity or polynomial growth. It is a choice of family, not a thermodynamic law. For observations y20,y25,y30, put d1=y25-y20, d2=y30-y25. Multiplying each observation by its denominator and subtracting gives\n r=(30*d2-20*d1)/(d1-d2),\n a=[y25*(25+r)-y20*(20+r)]/5,\n b=y20*(20+r)-20*a.\ncalorimetricCurve implements these inferred formulas directly using the supplied values. The identification lemmas independently show uniqueness of the three coefficient solutions. capacity_formula proves the simplified expressions:\n lower composition: (-13*t-2314)/(3*t+70);\n upper composition: (2*t-1275)/(t+45).\nNo capacity-sign or optimum was used as a calibration constraint.\n\nAt the actual concentration choose affinity in m between these two curves, and separately choose affinity in m for the 25 C relative enthalpy. Hence apparentCapacity(t)=4.184*((1-w)*lower(t)+w*upper(t)), and relative enthalpy at25 is 4.184*(87+w). Affine composition dependence is an independent approximation; two rows do NOT prove physical linearity. This is a new empirical representation rather than an asserted evaluation of the full original source model. Its applicability on19..100 C, far beyond the20..30 C fit, is an exposed assumption with NO certified extrapolation error or uniform comparison to Archer/Partanen. Conditional exact applicability is what the Lean theorem uses.\n\nThis gap is material. A held-out15 C comparison gives errors -0.4174 and-0.2500 cal/(mol K) at the bounding compositions. Synthetic diagnostics predict C_app at20,60,100 C around -80.48,-47.72,-33.92 J/(mol K) at the chosen m. They are calculations of this family, not measurements or uniform validation. They do not establish agreement with the diagnostic Archer variant, whose baseline and high-temperature behavior differ. The task'\"'s physical optimum cannot be asserted unconditionally from these fits. Another admissible empirical family or unbounded extrapolation error could change it. No global error tolerance is invented to preserve the recommendation.\n\nReference-state and mathematical meaning of the Lean premises.\nU(t) is enthalpy of original water plus pot; V(t) is enthalpy of final brine plus the same pot. K is enthalpy of the stored solid at20 C. Set d(t)=[V(t)-U(t)-K]/saltMoles, in J/mol. I=h_cr(25 C)-h_cr(20 C) is crystalline salt sensible enthalpy per mole, nonnegative from positive solid heat capacity. No numerical I or constant51 is needed. At25 C:\n d(25) = 4.184*(H+87+w)+I.\nThis adds same-temperature finite-concentration dissolution enthalpy to the solid20-to25 C sensible increment; it never labels isothermal dissolution enthalpy as the fixed-solid energy difference. Differentiating cancels the stored solid and pot, so d'=absolute C_app. The proof derives this from the component derivatives of U,V. This handles negative, temperature-dependent capacity change consistently, without a secant reduction.\n\ncw(t) is water's specific Cp in J/(kg K); p(t) is pot capacity in J/K. waterCapacity=cw*waterMass+p. The exposed independent property guards are cw>=4000 J/(kg K), p>=0 on19..100 C. The coarse water guard is physically motivated by liquid-water properties but is NOT a formally evaluated IAPWS bound. It replaces the old assumed aggregate C>=3900. U'=waterCapacity and V'=waterCapacity+saltMoles*apparentCapacity are the first-law storage definitions. Positive total capacities are derived from these component premises and the calibrated capacity bound. Pure-water enthalpy above its boiling point is only a formal liquid-reference continuation; the pure-water heating path itself stops at B0.\n\nN(t)=W-k*(t-20), shared before/after, is the human-accepted constant-input Newtonian-loss approximation. The theorem takes k>0 and W>k*(B-20), so net power is positive throughout the admissible paths. Neither W nor k is fitted or assigned a number. F'=U'/N and G'=V'/N define inverse first-law time primitives. Their additive constants cancel in totalTime=F(x)-F(20)+G(B)-G(z(x)). Thus these functions are not assumed timing optima or fitted elapsed-time observations.\n\nz(x) solves instantaneous energy conservation V(z(x))=U(x)+K. A differentiable mixing solution in19..B is an explicit remaining physical/domain guard; it is not supplied by a measured experiment or proved phase calculation. The identity is written for smooth formal extensions of the functions to permit ordinary derivatives, with physical applicability only on the stated intervals. Assume 20<=B0<=B<=100 C, complete dissolution, and liquid feasibility from19 C to B. B0 is pure-water boiling onset and B is brine boiling onset at the chosen pressure. These phase brackets and inverse-solution existence are independent assumptions, not certified consequences of the calorimetric fit. The old diagnostic roots support plausibility but are not promoted to premises proved from phase equilibrium. Addition x is restricted to [20,B0]; no waiting through unsalted boiling is allowed. The proof derives z(x)<x<=B from the balance and positive storage; its lower liquid bound and existence remain guarded. These unresolved guards must be reviewed with the empirical extrapolation.\n\nProved inference and concise translation of the statements.\ncomposition_inference derives solvent mass and composition bounds.\ncapacity_formula derives rational coefficients from the tabular inputs. capacity_bounds proves -100<=C_app<=0 on19..100 C and two affine lower bounds: -77+(25/35)*(t-25) on25..60 C and -52+(11/40)*(t-60) on60..100 C. These are exact bounds on the declared family, not observed material uncertainty intervals.\nmaterial_enthalpy_positive integrates those bounds by a differential comparison theorem. The25 C enthalpy is at least4225 J/mol. The maximum allowed decreases25->60 and60->100 are2257.5 and1860 J/mol; thus d(100)>=107.5>100 J/mol. Since C_app<=0, d decreases with temperature, so d(t)>100 for every20<=t<=100. This is a genuine full-interval theorem about the model, not a sampled-sign inference. The proof never presumes the desired mixing sign.\n\nsalt_timing_answer is the only final extracted conclusion. Conditional on its explicit calibration, reference-state, storage, phase/mixing, apparatus and inverse-first-law premises, it proves:\n (1) z(x)<x;\n (2) N(z(x))-N(x)=k*(x-z(x))>0, with the equality and strict comparison explicit;\n (3) totalTime(20)<=totalTime(x) for every admissible x.\nIt derives the mixing sign using strict increase of V and the proved d>0. Differentiating the conservation identity gives V'(z)*z'=U'(x). Differentiating both time stages then cancels the variable capacity terms and yields\n tau'(x)=U'(x)*(1/N(x)-1/N(z(x))).\nThe derived mixing/power inequalities make this nonnegative; a mean-value monotonicity theorem proves the global timing comparison. Therefore the conditional recommendation is immediate addition at20 C, with no optimal waiting duration. With an ideal lossless constant heater, energy conservation instead makes schedules tie; that general observation explains why unspecified apparatus cannot furnish a universal strict advantage, but the final Lean theorem specifically treats k>0.\n\nReview boundary and limitations.\nUser facts: volume, initial temperature, heating arrangement and unspecified remaining conditions.\nAdditional assumptions: selected10 g NaCl/20 C/0.100 MPa scenario; nominal reference properties and H interval; rational temperature family and its full19..100 C applicability; affine composition dependence for capacity and relative enthalpy; positive solid sensible increment; water/pot component guards; common net-power law; instantaneous conservative mixing; liquid/solubility/boiling and inverse-solution guards; inverse first-law primitives. These are all visible in definitions or the final theorem, not unproved intermediate lemmas.\nNecessary definitions: waterMass, saltMoles, blend, calorimetricCurve, apparentCapacity, waterCapacity, netPower, totalTime. Supporting algebra and parameter calculation are lemmas, not added review assumptions. No prior over-specific numerical duration, chosen pot mass, fabricated experiment, Bayesian prior, sorry or additional axiom is used.\nProved conclusion: conditional immediate-addition optimality plus the derived mixing and net-power changes. Lean establishes the implications, not physical truth of the empirical extension or guards. Failure to validate that extension is not repaired by a successful kernel check. Raw local Lean traces and synthetic diagnostics are retained in evidence/cycle9; actual harness records are in checks. This candidate is submitted for human review and is not self-approved.\n\nPrimary references retained with original pages and SHA256 manifests:\nParker1965, https://nvlpubs.nist.gov/nistpubs/Legacy/NSRDS/nbsnsrds2.pdf , DOI10.6028/NBS.NSRDS.2, pp26,43,50; /work/inputs/material-literature-002/sources.json.\nNIST GLP10 density, https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf ; NIST WebBook molar mass https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2 ; /work/inputs/material-evidence-001/sources.json.\nIAPWS95 and Archer PartI/II in retained evidence support the physical context but are not claimed as formally evaluated global material/phase certificates for this candidate.\nEOF\npython - <<'PY'\nimport json\nfrom pathlib import Path\nc={\n'proof_file':'Model.lean','narrative_file':'report.txt','conclusions':{'answer':'salt_timing_answer'},\n'user_facts':['One litre of water initially at20 degrees Celsius has been poured into a pot and heating on a stove has begun.','Salt will be added; its identity/quantity, the pot, heater and room conditions are otherwise unspecified.'],\n'model_choices':[\n'Retained illustrative scenario:10 g crystalline NaCl stored at20 C, original litre of air-free reference water at20 C, ambient/pot initially20 C, pressure0.100 MPa; instantaneous adiabatic complete dissolution, no evaporation, a common liquid/pot temperature. Derive solvent mass from NIST density and unit conversion, moles from58.443 g/mol, and molality/interpolation weight.',\n'Explicit representation change from rejected secant and uncertified Archer variant: fit rational capacity family (a*t+b)/(t+r) separately to Parker nominal20,25,30 C calorimetry at m=.1388,.1850. Derive parameters from these values. Choose affine composition dependence for capacity and25 C relative enthalpy. Choose exact applicability of this empirical family on19..100 C; this extrapolation/interpolation has no certified physical error bound and is an independent review assumption, not an evaluation/bound of the full source EOS.',\n'Parker25 C infinite-dilution solid dissolution enthalpy H in923..933 thermochemical cal/mol, motivated by928+/-5; finite-concentration relative values87 and88 cal/mol. Use consistent absolute apparent capacity, conversion4.184 J/cal, and fixed stored-solid20 C reference. I>=0 is solid sensible enthalpy20-to25 C; its magnitude is not assigned. Derive d prime=absolute C_app and uniform d>100 J/mol instead of assuming a mixing/cooling/optimum sign.',\n'Variable water and pot component capacities: cw>=4000 J/(kg K), pot capacity>=0 on19..100 C; water guard is independently exposed, not a certified IAPWS evaluation. Brine capacity equals original component storage plus n*C_app, and positivity follows in Lean. Pure-water reference continuation above its boiling point is not a stable pure-water heating path.',\n'Accepted shared Newtonian law N(t)=W-k*(t-20), k>0 and sufficient W>k*(B-20), with inverse first-law time primitives F prime=U prime/N, G prime=V prime/N. No numerical apparatus parameters or durations.',\n'Independent phase/domain guards:20<=pure-water boiling B0<=brine boiling B<=100 C at selected pressure; liquid and complete-dissolution regime from19 C to B; differentiable liquid-valued mixing solution obeying V(z)=U+K. Solvability/lower liquid bound and phase brackets are not proved from an EOS. Addition restricted to20..B0 with no unsalted boiling dwell. Derive z<x and resulting power increase and time comparison.'\n],\n'sources':[\n'Operator primary-source bundles /work/inputs/material-evidence-001/sources.json and /work/inputs/material-literature-002/sources.json; original PDFs/pages and hashes retained.',\n'https://nvlpubs.nist.gov/nistpubs/Legacy/NSRDS/nbsnsrds2.pdf — Parker1965 DOI10.6028/NBS.NSRDS.2, printed26/43/50, visually verified this cycle.',\n'https://www.nist.gov/system/files/documents/2017/05/09/NISTIR_7383_2013-04-24_2015-01-14.pdf — NIST reference water density20 C.',\n'https://webbook.nist.gov/cgi/cbook.cgi?ID=C7647145&Mask=2 — NaCl molar mass.',\n'/work/inputs/material-calculation-003/DIAGNOSTIC-NOTES.txt and /work/inputs/material-calculation-004/interval-certification-status.json — diagnostics and explicit certification failure, not uniform material evidence.'\n],\n'incorporated_inputs':['f7c987a52391410bb035542305825b3f','8ee08d44180740abb377ff631b6f1452','385ae674960d48e49d45526c2703465f','e619fbb0992b47fab14c4641bd0dcbf2'],\n'proof_scope':'Conditional scientific inference: derives material-family parameters and uniform capacity/enthalpy bounds from nominal calorimetric data plus an explicit rational-family/composition assumption; derives positive variable component storage, mixing cooling, related net-power increase and global immediate-addition optimality from energy conservation and inverse first-law heating. No sorry or additional axioms. Exact empirical applicability/extrapolation, water capacity guard, liquid/phase/mixing solvability and apparatus premises remain for human review; no certified physical error bound, measured duration, universal answer for unspecified salt/apparatus, or human acceptance is claimed.'\n}\nPath('/work/candidate.json').write_text(json.dumps(c,indent=2)+'\\\\n')\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json\""
}
shell input
{
  "command": "/usr/bin/bash -lc 'ls -lt /work/checks | head -4'"
}
shell output · exit 0
total 40
drwxr-xr-x 2 1001 1001 4096 Nov 18 02:31 2abfb9d0c1854fcf943c4d3ecad1151d
drwxr-xr-x 2 1001 1001 4096 Nov 17 23:45 0a52ddc3554b4e10b6c5b477fceb0093
drwxr-xr-x 2 1001 1001 4096 Nov 17 23:44 45e3bdc1f6974c4dae446c78777c9f79
shell output · exit 1 · failed
{
 "file": "/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/submitted.lean",
 "conclusions": [
  "salt_timing_answer"
 ],
 "lean_exit": 0,
 "ok": false,
 "compiles_alone": true,
 "faithful": {
  "salt_timing_answer": false
 },
 "assumption_declarations": [
  "waterMass",
  "saltMoles",
  "blend",
  "calorimetricCurve",
  "apparentCapacity",
  "netPower",
  "totalTime",
  "waterCapacity"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "salt_timing_answer": {
   "original_sha256": "7896377d88b362ac56f2dab6b98f6f2d8f0f73c62c1d052236831c3a809aec5c",
   "extracted_sha256": "d5d4170aedd90dd441206849187f98e2af9f3b11a404883f138fbce1cdbb2b6b"
  }
 },
 "dependency_faithful": {
  "saltMoles": true,
  "saltMoles._proof_1": true,
  "blend": true,
  "waterMass": true,
  "waterMass._proof_1": true,
  "waterCapacity": true,
  "apparentCapacity": true,
  "calorimetricCurve": true,
  "calorimetricCurve._proof_1": true,
  "calorimetricCurve._proof_2": true,
  "calorimetricCurve._proof_3": true,
  "calorimetricCurve._proof_4": true,
  "apparentCapacity._proof_1": true,
  "netPower": true,
  "totalTime": true
 },
 "dependency_identities": {
  "saltMoles": {
   "original_sha256": "827bccd82e2687317f9129d38e31997f9f2a83127c0fcf5ab6bf61c947140dd5",
   "extracted_sha256": "827bccd82e2687317f9129d38e31997f9f2a83127c0fcf5ab6bf61c947140dd5"
  },
  "saltMoles._proof_1": {
   "original_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e",
   "extracted_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e"
  },
  "blend": {
   "original_sha256": "0564ab882bd3f394420c6568a2a76aa7f9c3239ab5f7a2d7a22c57e50cf1192a",
   "extracted_sha256": "0564ab882bd3f394420c6568a2a76aa7f9c3239ab5f7a2d7a22c57e50cf1192a"
  },
  "waterMass": {
   "original_sha256": "54cdbd23ea81ba012ab9e6257436e9f54431a1eec79c5351523168154c27f078",
   "extracted_sha256": "54cdbd23ea81ba012ab9e6257436e9f54431a1eec79c5351523168154c27f078"
  },
  "waterMass._proof_1": {
   "original_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8",
   "extracted_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8"
  },
  "waterCapacity": {
   "original_sha256": "5ad429c7ec6f40440a6d5a145584438fb93a8b06f115cc9010f714bb382dd411",
   "extracted_sha256": "5ad429c7ec6f40440a6d5a145584438fb93a8b06f115cc9010f714bb382dd411"
  },
  "apparentCapacity": {
   "original_sha256": "ee228915221a930df961bddf28427bb24076b73fbab345b3a0d9cde5f78df92b",
   "extracted_sha256": "ee228915221a930df961bddf28427bb24076b73fbab345b3a0d9cde5f78df92b"
  },
  "calorimetricCurve": {
   "original_sha256": "4a4538aa3d3e0d4285eecafdac9d81b13ad47e8d382f5eb7964cac93e33ab328",
   "extracted_sha256": "4a4538aa3d3e0d4285eecafdac9d81b13ad47e8d382f5eb7964cac93e33ab328"
  },
  "calorimetricCurve._proof_1": {
   "original_sha256": "e72460529fc291789692b7a1d53e45b82e9c6684e8a3b5aa7472abea5e34b3a4",
   "extracted_sha256": "e72460529fc291789692b7a1d53e45b82e9c6684e8a3b5aa7472abea5e34b3a4"
  },
  "calorimetricCurve._proof_2": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "calorimetricCurve._proof_3": {
   "original_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae",
   "extracted_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae"
  },
  "calorimetricCurve._proof_4": {
   "original_sha256": "27a39ed7b1e9bbfe47c55794101d03a078de3a98d6b443fa3f39bbcb7f2437f9",
   "extracted_sha256": "27a39ed7b1e9bbfe47c55794101d03a078de3a98d6b443fa3f39bbcb7f2437f9"
  },
  "apparentCapacity._proof_1": {
   "original_sha256": "e7b45ed9c39659bc3b75357c46a1fa7efb15b8a0ab988e5dd0a24be646eb78f2",
   "extracted_sha256": "e7b45ed9c39659bc3b75357c46a1fa7efb15b8a0ab988e5dd0a24be646eb78f2"
  },
  "netPower": {
   "original_sha256": "3e22db0bc6aca59f93d188b3dab392fb5b33da7408ccc32ba5341d0ad4528095",
   "extracted_sha256": "3e22db0bc6aca59f93d188b3dab392fb5b33da7408ccc32ba5341d0ad4528095"
  },
  "totalTime": {
   "original_sha256": "ea4c6b4956d1767cf210da50bc45b391b0e0832264ed239f47d0d7f14eeb7b46",
   "extracted_sha256": "ea4c6b4956d1767cf210da50bc45b391b0e0832264ed239f47d0d7f14eeb7b46"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "salt_timing_answer": "\u2200 (U V cw p F G z : \u211d \u2192 \u211d) (K I H W k B0 B x : \u211d), 0 \u2264 I \u2192 923 \u2264 H \u2192 H \u2264 933 \u2192 V 25 - U 25 - K = saltMoles * (4.184 * (H + 87 + blend) + I) \u2192 (\u2200 t \u2208 Set.Icc 19 100, 4000 \u2264 cw t \u2227 0 \u2264 p t) \u2192 (\u2200 t \u2208 Set.Icc 19 100, HasDerivAt U (waterCapacity cw p t) t) \u2192 (\u2200 t \u2208 Set.Icc 19 100, HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) \u2192 20 \u2264 B0 \u2192 B0 \u2264 B \u2192 B \u2264 100 \u2192 0 < k \u2192 k * (B - 20) < W \u2192 (\u2200 (y : \u211d), V (z y) = U y + K) \u2192 (\u2200 y \u2208 Set.Icc 20 B0, z y \u2208 Set.Icc 19 B \u2227 DifferentiableAt \u211d z y) \u2192 (\u2200 t \u2208 Set.Icc 19 B, HasDerivAt F (waterCapacity cw p t / netPower W k t) t \u2227 HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t) \u2192 x \u2208 Set.Icc 20 B0 \u2192 z x < x \u2227 netPower W k (z x) - netPower W k x = k * (x - z x) \u2227 netPower W k x < netPower W k (z x) \u2227 totalTime F G z B 20 \u2264 totalTime F G z B x"
 },
 "extracted_file": "/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/extracted.lean",
 "errors": []
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-18T02:31:02.789947+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
assistant
The review packet now identifies two limits on the recommendation: the fitted capacity curves have no validated error bound up to boiling, and the liquid-state and mixing-solvability conditions remain assumptions. The harness check is running. A successful check would establish the stated conditional implication, not validate those physical assumptions.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -la /work/checks/2abfb9d0c1854fcf943c4d3ecad1151d; cat /work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/feedback.json'"
}
shell output · exit 1 · failed
total 88
drwxr-xr-x  2 1001 1001  4096 Nov 18 02:31 .
drwxr-xr-x 12 1001 1001  4096 Nov 18 02:31 ..
-rw-r--r--  1 1001 1001 17885 Nov 18 02:31 Checked.lean
-rw-r--r--  1 1001 1001  5619 Nov 18 02:31 extracted.json
-rw-r--r--  1 1001 1001  2133 Nov 18 02:31 extracted.lean
-rw-r--r--  1 1001 1001  1780 Nov 18 02:31 lean.log
-rw-------  1 1001 1001  4513 Nov 18 02:31 submitted-candidate.json
-rw-r--r--  1 1001 1001 13301 Nov 18 02:31 submitted-report.txt
-rw-r--r--  1 1001 1001 14712 Nov 18 02:31 submitted.lean
-rw-------  1 1001 1001   203 Nov 18 02:31 verdict.json
cat: /work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/feedback.json: No such file or directory
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/extracted.lean; cat /work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/lean.log'"
}
shell output · exit 0
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import Mathlib.Tactic.NormNum

noncomputable def waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000

noncomputable def saltMoles : ℝ := 10 / 58.443

noncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)

noncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=
  let d1 := y25-y20
  let d2 := y30-y25
  let r := (30*d2-20*d1)/(d1-d2)
  let a := (y25*(25+r)-y20*(20+r))/5
  let b := y20*(20+r)-20*a
  (a*t+b)/(t+r)

noncomputable def apparentCapacity (t : ℝ) : ℝ :=
  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +
    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)

def netPower (W k t : ℝ) : ℝ := W - k * (t - 20)

noncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=
  F x - F 20 + G B - G (z x)

noncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=
  waterMass * cw t + p t


/-! Conclusions (statements of the proved theorems). -/
def conclusion_salt_timing_answer : Prop := ∀ (U V cw p F G z : ℝ → ℝ) (K I H W k B0 B x : ℝ), 0 ≤ I → 923 ≤ H → H ≤ 933 → V 25 - U 25 - K = saltMoles * (4.184*(H+87+blend)+I) → (∀ t ∈ Set.Icc 19 100, 4000 ≤ cw t ∧ 0 ≤ p t) → (∀ t ∈ Set.Icc 19 100, HasDerivAt U (waterCapacity cw p t) t) → (∀ t ∈ Set.Icc 19 100, HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) → 20 ≤ B0 → B0 ≤ B → B ≤ 100 → 0 < k → k*(B-20) < W → (∀ y, V (z y) = U y + K) → (∀ y ∈ Set.Icc 20 B0, z y ∈ Set.Icc 19 B ∧ DifferentiableAt ℝ z y) → (∀ t ∈ Set.Icc 19 B, HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧ HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t) → x ∈ Set.Icc 20 B0 → z x < x ∧ netPower W k (z x) - netPower W k x = k*(x-z x) ∧ netPower W k x < netPower W k (z x) ∧ totalTime F G z B 20 ≤ totalTime F G z B x
/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/Checked.lean:44:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/Checked.lean:44:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/Checked.lean:179:24: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/Checked.lean:179:28: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/Checked.lean:190:24: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/Checked.lean:190:28: warning: Unused tactic linter: `ring` does nothing.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/Checked.lean:179:28: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
/work/checks/2abfb9d0c1854fcf943c4d3ecad1151d/Checked.lean:190:28: warning: this tactic is never executed

Note: This linter can be disabled with `set_option linter.unreachableTactic false`
'salt_timing_answer' depends on axioms: [propext, Classical.choice, Quot.sound]
VAS_LISTED

leanchecker exit 0

assistant
The first harness run compiled the proof and completed the kernel check, but the independently extracted theorem did not match the original statement. That is a failed check under the protocol. I’ll fix the statement’s elaboration so extraction preserves it exactly, then rerun the harness.
shell input
{
  "command": "/usr/bin/bash -lc \"grep -n 'identity\\\\|repr\\\\|faithful' /harness/src/vcs_extract.py | head -35; cat /work/history/cycle5-start/Model.lean | tail -8; grep -n 'extraction\\\\|cast\\\\|numeral' /work/history/cycle5-start/report.txt /work/evidence/cycle6/revision-notes.txt\""
}
shell output · exit 0
20:# levels, implicit arguments and binder information remain in the identity.
22:private partial def VAS_identityExpr : Lean.Expr → Lean.Expr
23:  | .mdata _ value => VAS_identityExpr value
24:  | .app fn arg => .app (VAS_identityExpr fn) (VAS_identityExpr arg)
25:  | .lam _ typ body info => .lam .anonymous (VAS_identityExpr typ) (VAS_identityExpr body) info
26:  | .forallE _ typ body info => .forallE .anonymous (VAS_identityExpr typ) (VAS_identityExpr body) info
27:  | .letE _ typ value body flag => .letE .anonymous (VAS_identityExpr typ) (VAS_identityExpr value) (VAS_identityExpr body) flag
28:  | .proj owner idx value => .proj owner idx (VAS_identityExpr value)
38:    | .inductInfo info => s!"inductive {info.numParams} {info.numIndices} {reprStr info.ctors}"
42:    | some body => reprStr (VAS_identityExpr body)
44:  s!"{kind}|levels={reprStr ci.levelParams}|type={reprStr (VAS_identityExpr ci.type)}|value={value}"
59:    logInfo m!"VAS_ORIGINAL_IDENTITY {t} : {reprStr (VAS_identityExpr ci.type)} VAS_END"
93:    logInfo m!"VAS_EXTRACTED_IDENTITY {n} : {reprStr (VAS_identityExpr v)} VAS_END"
122:            raise ValueError(f"duplicate expression identity for {name}")
230:    identity_hashes = {
244:               "faithful": same, "assumption_declarations": [owner[r] for r in keep],
245:               "identity_method": "kernel-expression-repr-v1", "conclusion_identities": identity_hashes,
246:               "dependency_faithful": dependencies_same, "dependency_identities": dependency_hashes,
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
/work/history/cycle5-start/report.txt:80:Cycle 1 left independent before/after powers and was rejected after formal verification; its files remain in history/cycle1. Cycle 2 used one shared heat-transfer law but assumed nonnegative additive S and insufficiently specified H's reference; its checked mathematical implication was rejected by the human for those scientific reasons. The submitted cycle-2 files and rejection are preserved in history/cycle2. This cycle retains the accepted heat-transfer approximation but corrects S, H and the feasible timing domain and replaces the old recommendation with complete conditional regimes. Prior checks and diagnostics were read, including the earlier independent-extraction failure and subsequent faithful extraction result. Raw traces remain unchanged.
/work/evidence/cycle6/revision-notes.txt:3:Read the task-local history, cycle5 report/proof/calibration, current human-feedback.json, material response f7c987a52391410bb035542305825b3f and primary-source excerpts. Preserved rejected files in history/cycle6-start/. The last actual check is checks/0a52ddc3554b4e10b6c5b477fceb0093: proved, complete independent extraction and kernel recheck. Earlier cycle5 checks failed extraction identity and one proof elaboration; those were fixed by explicit casts and proof-local normalization. These diagnostics do NOT address the material-model defects identified by the subsequent human rejection. No human approval is inferred.
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport re\np='/work/Model.lean';s=open(p).read();i=s.index('theorem salt_timing_answer :');j=s.index(' := by',i)\na=s[i:j]\na=re.sub(r'(?<\"'!['\"\\\\w.])(\\\\d+)(?\"'!['\"\\\\w.])',lambda m:'(('+m.group()+' : ℕ) : ℝ)',a)\ns=s[:i]+a+s[j:]\nneedle='    hB0 hB0B hB hk hW hmix hz hFG hx\\\\n'\ns=s.replace(needle,needle+'''  norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV\n    hB0 hB0B hB hk hW hmix hz hFG hx ⊢\n''')\n# clean warnings harmless\ns=s.replace('ext v; simp <;> ring','ext v; simp')\nopen(p,'w').write(s)\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json\""
}
shell output · exit 1 · failed
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-18T02:32:36.232199+00:00",
  "lean_exit": 1,
  "error": "Lean, kernel recheck or axiom audit failed; see lean.log"
}
shell input
{
  "command": "/usr/bin/bash -lc 'ls -lt /work/checks | head -3'"
}
shell output · exit 0
total 44
drwxr-xr-x 2 1001 1001 4096 Nov 18 02:32 b140062e8fd043a79dde530ae0be409e
drwxr-xr-x 2 1001 1001 4096 Nov 18 02:31 2abfb9d0c1854fcf943c4d3ecad1151d
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/b140062e8fd043a79dde530ae0be409e/lean.log'"
}
shell output · exit 0
/work/checks/b140062e8fd043a79dde530ae0be409e/Checked.lean:44:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/b140062e8fd043a79dde530ae0be409e/Checked.lean:44:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/b140062e8fd043a79dde530ae0be409e/Checked.lean:235:62: error: unsolved goals
U V cw p F G z : ℝ → ℝ
K I H W k B0 B x : ℝ
hB0 : ↑20 ≤ B0
hB0B : B0 ≤ B
hB : B ≤ ↑100
hk : ↑0 < k
hW : k * (B - ↑20) < W
hmix : ∀ (y : ℝ), V (z y) = U y + K
hz : ∀ y ∈ Set.Icc (↑20) B0, z y ∈ Set.Icc (↑19) B ∧ DifferentiableAt ℝ z y
hFG :
  ∀ t ∈ Set.Icc (↑19) B,
    HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
      HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t
hx : x ∈ Set.Icc (↑20) B0
hI : 0 ≤ I
hH : 923 ≤ H
hHhi : H ≤ 933
ha : V 25 - U 25 - K = saltMoles * (523 / 125 * (H + 87 + blend) + I)
hcomponents : ∀ t ∈ Set.Icc 19 100, 4000 ≤ cw t ∧ 0 ≤ p t
hU : ∀ t ∈ Set.Icc 19 100, HasDerivAt U (waterCapacity cw p t) t
hV : ∀ t ∈ Set.Icc 19 100, HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t
⊢ z x < x ∧
    netPower W k (z x) - netPower W k x = k * (x - z x) ∧
      netPower W k x < netPower W k (z x) ∧ totalTime F G z B ↑20 ≤ totalTime F G z B x
/work/checks/b140062e8fd043a79dde530ae0be409e/Checked.lean:239:4: error: unexpected identifier; expected command
'salt_timing_answer' depends on axioms: [propext, sorryAx, Classical.choice, Quot.sound]
VAS_GAP salt_timing_answer used=true : (U : ℝ →
  ℝ) (V : ℝ →
  ℝ) (cw : ℝ →
  ℝ) (p : ℝ →
  ℝ) (F : ℝ →
  ℝ) (G : ℝ →
  ℝ) (z : ℝ →
  ℝ) (K : ℝ) (I : ℝ) (H : ℝ) (W : ℝ) (k : ℝ) (B0 : ℝ) (B : ℝ) (x : ℝ) (hI : ↑0 ≤
  I) (hH : ↑923 ≤
  H) (hHhi : H ≤
  ↑933) (ha : V ↑25 - U ↑25 - K =
  saltMoles *
    (4.184 * (H + ↑87 + blend) +
      I)) (hcomponents : ∀ t ∈ Set.Icc ↑19 ↑100,
  ↑4000 ≤ cw t ∧
    ↑0 ≤
      p
        t) (hU : ∀ t ∈ Set.Icc ↑19 ↑100,
  HasDerivAt U (waterCapacity cw p t)
    t) (hV : ∀ t ∈ Set.Icc ↑19 ↑100,
  HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t)
    t) (hB0 : ↑20 ≤
  B0) (hB0B : B0 ≤
  B) (hB : B ≤
  ↑100) (hk : ↑0 <
  k) (hW : k * (B - ↑20) <
  W) (hmix : ∀ (y : ℝ),
  V (z y) =
    U y +
      K) (hz : ∀ y ∈ Set.Icc (↑20) B0,
  z y ∈ Set.Icc (↑19) B ∧
    DifferentiableAt ℝ z
      y) (hFG : ∀ t ∈ Set.Icc (↑19) B,
  HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
    HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t)
      t) (hx : x ∈
  Set.Icc (↑20)
    B0) ⊢ z x < x ∧
  netPower W k (z x) - netPower W k x = k * (x - z x) ∧
    netPower W k x < netPower W k (z x) ∧ totalTime F G z B ↑20 ≤ totalTime F G z B x VAS_END
VAS_LISTED
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '230,250p' /work/Model.lean\""
}
shell output · exit 0
        netPower W k t) t) →
    x ∈ Set.Icc ((20 : ℕ) : ℝ) B0 →
    z x < x ∧
    netPower W k (z x) - netPower W k x = k*(x-z x) ∧
    netPower W k x < netPower W k (z x) ∧
    totalTime F G z B ((20 : ℕ) : ℝ) ≤ totalTime F G z B x := by
  intro U V cw p F G z K I H W k B0 B x hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx
  norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx ⊢
  obtain ⟨hmass, hn, hnhi, hw, hw1⟩ := composition_inference
  have hN : saltMoles ≠ 0 := ne_of_gt hn
  have hstorage : ∀ t ∈ Set.Icc 19 100,
      0 < waterCapacity cw p t ∧
      0 < waterCapacity cw p t + saltMoles * apparentCapacity t := by
    intro t ht
    obtain ⟨hcw, hp⟩ := hcomponents t ht
    have hcp := (capacity_bounds t ht).1
    have hbound := mul_nonneg (le_of_lt hn) (show 0 ≤ apparentCapacity t + 100 by linarith)
    unfold waterCapacity
    rw [hmass]
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean';s=open(p).read().replace('norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV\\\\n    hB0 hB0B hB hk hW hmix hz hFG hx ⊢','norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV hB0 hB0B hB hk hW hmix hz hFG hx ⊢');open(p,'w').write(s)\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json\""
}
shell output · exit 1 · failed
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-18T02:33:14.509364+00:00",
  "lean_exit": 1,
  "error": "Lean, kernel recheck or axiom audit failed; see lean.log"
}
shell input
{
  "command": "/usr/bin/bash -lc 'ls -t /work/checks | head -1'"
}
shell output · exit 0
827f88bd852b4d06a3f5f893832d7056
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/checks/827f88bd852b4d06a3f5f893832d7056/lean.log'"
}
shell output · exit 0
/work/checks/827f88bd852b4d06a3f5f893832d7056/Checked.lean:44:4: warning: Unused tactic linter: `<;>` should be replaced with `;` or be removed.

Note: This linter can be disabled with `set_option linter.unusedTactic false`
/work/checks/827f88bd852b4d06a3f5f893832d7056/Checked.lean:44:4: warning: Used `tac1 <;> tac2` where `(tac1; tac2)` would suffice

Note: This linter can be disabled with `set_option linter.unnecessarySeqFocus false`
/work/checks/827f88bd852b4d06a3f5f893832d7056/Checked.lean:254:4: error: unsolved goals
case a
U V cw p F G z : ℝ → ℝ
K I H W k B0 B x : ℝ
hB0B : B0 ≤ B
hmix : ∀ (y : ℝ), V (z y) = U y + K
hI : 0 ≤ I
hH : 923 ≤ H
hHhi : H ≤ 933
ha : V 25 - U 25 - K = saltMoles * (523 / 125 * (H + 87 + blend) + I)
hcomponents : ∀ t ∈ Set.Icc 19 100, 4000 ≤ cw t ∧ 0 ≤ p t
hU : ∀ t ∈ Set.Icc 19 100, HasDerivAt U (waterCapacity cw p t) t
hV : ∀ t ∈ Set.Icc 19 100, HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t
hB0 : 20 ≤ B0
hB : B ≤ 100
hk : 0 < k
hW : k * (B - 20) < W
hz : ∀ y ∈ Set.Icc 20 B0, z y ∈ Set.Icc 19 B ∧ DifferentiableAt ℝ z y
hFG :
  ∀ t ∈ Set.Icc 19 B,
    HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
      HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t
hx : x ∈ Set.Icc 20 B0
hmass : waterMass = 0.99820675
hn : 0 < saltMoles
hnhi : saltMoles < 0.18
hw : 0 ≤ blend
hw1 : blend ≤ 1
hN : saltMoles ≠ 0
hstorage : ∀ t ∈ Set.Icc 19 100, 0 < waterCapacity cw p t ∧ 0 < waterCapacity cw p t + saltMoles * apparentCapacity t
⊢ 523 * (H + 87 + blend) + 125 * I = 125 * ((H + 87 + blend) * 4.184 + I)
'salt_timing_answer' depends on axioms: [propext, sorryAx, Classical.choice, Quot.sound]
VAS_GAP salt_timing_answer used=true : (U : ℝ →
  ℝ) (V : ℝ →
  ℝ) (cw : ℝ →
  ℝ) (p : ℝ →
  ℝ) (F : ℝ →
  ℝ) (G : ℝ →
  ℝ) (z : ℝ →
  ℝ) (K : ℝ) (I : ℝ) (H : ℝ) (W : ℝ) (k : ℝ) (B0 : ℝ) (B : ℝ) (x : ℝ) (hI : ↑0 ≤
  I) (hH : ↑923 ≤
  H) (hHhi : H ≤
  ↑933) (ha : V ↑25 - U ↑25 - K =
  saltMoles *
    (4.184 * (H + ↑87 + blend) +
      I)) (hcomponents : ∀ t ∈ Set.Icc ↑19 ↑100,
  ↑4000 ≤ cw t ∧
    ↑0 ≤
      p
        t) (hU : ∀ t ∈ Set.Icc ↑19 ↑100,
  HasDerivAt U (waterCapacity cw p t)
    t) (hV : ∀ t ∈ Set.Icc ↑19 ↑100,
  HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t)
    t) (hB0 : ↑20 ≤
  B0) (hB0B : B0 ≤
  B) (hB : B ≤
  ↑100) (hk : ↑0 <
  k) (hW : k * (B - ↑20) <
  W) (hmix : ∀ (y : ℝ),
  V (z y) =
    U y +
      K) (hz : ∀ y ∈ Set.Icc (↑20) B0,
  z y ∈ Set.Icc (↑19) B ∧
    DifferentiableAt ℝ z
      y) (hFG : ∀ t ∈ Set.Icc (↑19) B,
  HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
    HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t)
      t) (hx : x ∈
  Set.Icc (↑20)
    B0) (hmass : waterMass =
  0.99820675) (right._@.Checked.1725357720._hygCtx._hyg.722 : 0 < saltMoles ∧
  saltMoles < 0.18 ∧
    0 ≤ blend ∧
      blend ≤
        1) (hn : 0 <
  saltMoles) (right._@.Checked.1725357720._hygCtx._hyg.723 : saltMoles < 0.18 ∧
  0 ≤ blend ∧
    blend ≤
      1) (hnhi : saltMoles <
  0.18) (right._@.Checked.1725357720._hygCtx._hyg.724 : 0 ≤ blend ∧
  blend ≤
    1) (hw : 0 ≤
  blend) (hw1 : blend ≤
  1) (hN : saltMoles ≠
  0 := ne_of_gt
  hn) (hstorage : ∀ t ∈ Set.Icc 19 100,
  0 < waterCapacity cw p t ∧
    0 <
      waterCapacity cw p t +
        saltMoles *
          apparentCapacity
            t := fun t ht =>
  And.casesOn
    (Eq.mp
      (forall_congr fun t =>
        implies_congr
          (congrFun'
            (congrArg Membership.mem
              (congr
                (congrArg Set.Icc
                  (Mathlib.Meta.NormNum.IsNat.to_eq
                    (Mathlib.Meta.NormNum.isNat_natCast 19 19 (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 19)))
                    (Eq.refl 19)))
                (Mathlib.Meta.NormNum.IsNat.to_eq
                  (Mathlib.Meta.NormNum.isNat_natCast 100 100 (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 100)))
                  (Eq.refl 100))))
            t)
          (congr
            (congrArg And
              (congrFun'
                (congrArg LE.le
                  (Mathlib.Meta.NormNum.IsNat.to_eq
                    (Mathlib.Meta.NormNum.isNat_natCast 4000 4000 (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 4000)))
                    (Eq.refl 4000)))
                (cw t)))
            (congrFun'
              (congrArg LE.le
                (Mathlib.Meta.NormNum.IsNat.to_eq
                  (Mathlib.Meta.NormNum.isNat_natCast 0 0 (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 0)))
                  Nat.cast_zero))
              (p t))))
      hcomponents t ht)
    fun hcw hp =>
    have hcp := (capacity_bounds t ht).left;
    have hbound :=
      mul_nonneg (le_of_lt hn)
        (have this :=
          le_of_not_gt fun a =>
            Mathlib.Tactic.Linarith.lt_irrefl
              (Eq.mp
                (congrArg (fun _a => _a < 0)
                  (Mathlib.Tactic.Ring.of_eq
                    (Mathlib.Tactic.Ring.Common.add_congr
                      (Mathlib.Tactic.Ring.Common.sub_congr
                        (Mathlib.Tactic.Ring.Common.neg_congr
                          (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 100)))
                          (Mathlib.Tactic.Ring.Common.neg_add
                            (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                              (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 100))
                                (Eq.refl (Int.negOfNat 100))))
                            Mathlib.Tactic.Ring.Common.neg_zero))
                        (Mathlib.Tactic.Ring.Common.atom_pf (apparentCapacity t) rfl
                          (Eq.mpr
                            (id
                              (congrArg
                                (fun _a =>
                                  apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 =
                                    apparentCapacity t ^ Nat.rawCast 1 * _a)
                                (Eq.symm rfl)))
                            (Eq.refl (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                        (Mathlib.Tactic.Ring.Common.sub_pf
                          (Mathlib.Tactic.Ring.Common.neg_add
                            (Mathlib.Tactic.Ring.Common.neg_mul (apparentCapacity t) (Nat.rawCast 1)
                              (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                  (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                  (Eq.refl (Int.negOfNat 1)))))
                            Mathlib.Tactic.Ring.Common.neg_zero)
                          (Mathlib.Tactic.Ring.Common.add_pf_add_lt (Int.negOfNat 100).rawCast
                            (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                              (apparentCapacity t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0)))))
                      (Mathlib.Tactic.Ring.Common.sub_congr
                        (Mathlib.Tactic.Ring.Common.add_congr
                          (Mathlib.Tactic.Ring.Common.atom_pf (apparentCapacity t) rfl
                            (Eq.mpr
                              (id
                                (congrArg
                                  (fun _a =>
                                    apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 =
                                      apparentCapacity t ^ Nat.rawCast 1 * _a)
                                  (Eq.symm rfl)))
                              (Eq.refl (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                          (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 100)))
                          (Mathlib.Tactic.Ring.Common.add_pf_add_gt (Nat.rawCast 100)
                            (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                              (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))))
                        (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))
                        (Mathlib.Tactic.Ring.Common.sub_pf Mathlib.Tactic.Ring.Common.neg_zero
                          (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                            (Nat.rawCast 100 + (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0)))))
                      (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                        (Mathlib.Meta.NormNum.IsInt.to_isNat
                          (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                            (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 100))
                            (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 100))
                            (Eq.refl (Int.ofNat 0))))
                        (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                          (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero (apparentCapacity t) (Nat.rawCast 1)
                            (Mathlib.Meta.NormNum.IsInt.to_isNat
                              (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                (Eq.refl (Int.ofNat 0)))))
                          (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0))))
                    (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))))
                (Mathlib.Tactic.Linarith.add_lt_of_le_of_neg (Mathlib.Tactic.Linarith.sub_nonpos_of_le hcp)
                  (Mathlib.Tactic.Linarith.sub_neg_of_lt a)));
        this);
    id
      (Eq.mpr
        (id (congrArg (fun _a => 0 < _a * cw t + p t ∧ 0 < _a * cw t + p t + saltMoles * apparentCapacity t) hmass))
        ⟨lt_of_not_ge fun a =>
            Mathlib.Tactic.Linarith.lt_irrefl
              (Eq.mp
                (congrArg (fun _a => _a < 0)
                  (Mathlib.Tactic.Ring.of_eq
                    (Mathlib.Tactic.Ring.Common.add_congr
                      (Mathlib.Tactic.Ring.Common.add_congr
                        (Mathlib.Tactic.Ring.Common.add_congr
                          (Mathlib.Tactic.Ring.Common.add_congr
                            (Mathlib.Tactic.Ring.Common.mul_congr
                              (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 798565400000)))
                              (Mathlib.Tactic.Ring.Common.sub_congr
                                (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))
                                (Mathlib.Tactic.Ring.Common.atom_pf saltMoles rfl
                                  (Eq.mpr
                                    (id
                                      (congrArg
                                        (fun _a =>
                                          saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 = saltMoles ^ Nat.rawCast 1 * _a)
                                        (Eq.symm rfl)))
                                    (Eq.refl (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                (Mathlib.Tactic.Ring.Common.sub_pf
                                  (Mathlib.Tactic.Ring.Common.neg_add
                                    (Mathlib.Tactic.Ring.Common.neg_mul saltMoles (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                        (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                          (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                          (Eq.refl (Int.negOfNat 1)))))
                                    Mathlib.Tactic.Ring.Common.neg_zero)
                                  (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                    (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0))))
                              (Mathlib.Tactic.Ring.Common.add_mul
                                (Mathlib.Tactic.Ring.Common.mul_add
                                  (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                      (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.IsNat.to_isInt
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 798565400000))
                                        (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                        (Eq.refl (Int.negOfNat 798565400000)))))
                                  (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 798565400000))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 798565400000).rawCast + 0)))
                                (Mathlib.Tactic.Ring.Common.zero_mul
                                  (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 798565400000).rawCast + 0))))
                            (Mathlib.Tactic.Ring.Common.mul_congr
                              (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 15971308000)))
                              (Mathlib.Tactic.Ring.Common.sub_congr
                                (Mathlib.Tactic.Ring.Common.mul_congr
                                  (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)))
                                  (Mathlib.Tactic.Ring.Common.atom_pf saltMoles rfl
                                    (Eq.mpr
                                      (id
                                        (congrArg
                                          (fun _a =>
                                            saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 = saltMoles ^ Nat.rawCast 1 * _a)
                                          (Eq.symm rfl)))
                                      (Eq.refl (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                  (Mathlib.Tactic.Ring.Common.add_mul
                                    (Mathlib.Tactic.Ring.Common.mul_add
                                      (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                        (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                          (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 50)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 50))))
                                      (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 50))
                                      (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                        (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 50 + 0)))
                                    (Mathlib.Tactic.Ring.Common.zero_mul
                                      (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 50 + 0))))
                                (Mathlib.Tactic.Ring.Common.mul_congr
                                  (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                  (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 9)))
                                  (Mathlib.Tactic.Ring.Common.add_mul
                                    (Mathlib.Tactic.Ring.Common.mul_add
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9) (Eq.refl 9)))
                                      (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 1))
                                      (Mathlib.Tactic.Ring.Common.add_pf_add_zero (Nat.rawCast 9 + 0)))
                                    (Mathlib.Tactic.Ring.Common.zero_mul (Nat.rawCast 9 + 0))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero (Nat.rawCast 9 + 0))))
                                (Mathlib.Tactic.Ring.Common.sub_pf
                                  (Mathlib.Tactic.Ring.Common.neg_add
                                    (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                      (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                        (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9))
                                        (Eq.refl (Int.negOfNat 9))))
                                    Mathlib.Tactic.Ring.Common.neg_zero)
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_gt (Int.negOfNat 9).rawCast
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 50 + 0)))))
                              (Mathlib.Tactic.Ring.Common.add_mul
                                (Mathlib.Tactic.Ring.Common.mul_add
                                  (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                    (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                      (Mathlib.Meta.NormNum.IsNat.to_isInt
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 15971308000))
                                      (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 9))
                                      (Eq.refl (Int.negOfNat 143741772000))))
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 15971308000)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 50) (Eq.refl 798565400000))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 15971308000))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 798565400000 + 0)))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_lt (Int.negOfNat 143741772000).rawCast
                                    (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                      (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 798565400000 + 0))))
                                (Mathlib.Tactic.Ring.Common.zero_mul
                                  ((Int.negOfNat 9).rawCast + (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 50 + 0)))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  ((Int.negOfNat 143741772000).rawCast +
                                    (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 798565400000 + 0)))))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_gt (Int.negOfNat 143741772000).rawCast
                              (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                                (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero saltMoles (Nat.rawCast 1)
                                  (Mathlib.Meta.NormNum.IsInt.to_isNat
                                    (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                      (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 798565400000))
                                      (Mathlib.Meta.NormNum.IsNat.to_isInt
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 798565400000))
                                      (Eq.refl (Int.ofNat 0)))))
                                (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0))))
                          (Mathlib.Tactic.Ring.Common.mul_congr
                            (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 35935443)))
                            (Mathlib.Tactic.Ring.Common.sub_congr
                              (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000)))
                              (Mathlib.Tactic.Ring.Common.atom_pf (cw t) rfl
                                (Eq.mpr
                                  (id
                                    (congrArg
                                      (fun _a => cw t ^ Nat.rawCast 1 * Nat.rawCast 1 = cw t ^ Nat.rawCast 1 * _a)
                                      (Eq.symm rfl)))
                                  (Eq.refl (cw t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                              (Mathlib.Tactic.Ring.Common.sub_pf
                                (Mathlib.Tactic.Ring.Common.neg_add
                                  (Mathlib.Tactic.Ring.Common.neg_mul (cw t) (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                      (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                        (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                        (Eq.refl (Int.negOfNat 1)))))
                                  Mathlib.Tactic.Ring.Common.neg_zero)
                                (Mathlib.Tactic.Ring.Common.add_pf_add_lt (Nat.rawCast 4000)
                                  (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                    (cw t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0)))))
                            (Mathlib.Tactic.Ring.Common.add_mul
                              (Mathlib.Tactic.Ring.Common.mul_add
                                (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                  (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 35935443)
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000) (Eq.refl 143741772000)))
                                (Mathlib.Tactic.Ring.Common.mul_add
                                  (Mathlib.Tactic.Ring.Common.mul_pf_right (cw t) (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                      (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.IsNat.to_isInt
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 35935443))
                                        (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                        (Eq.refl (Int.negOfNat 35935443)))))
                                  (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 35935443))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast + 0)))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_lt (Nat.rawCast 143741772000)
                                  (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                    (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast + 0))))
                              (Mathlib.Tactic.Ring.Common.zero_mul
                                (Nat.rawCast 4000 + (cw t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0)))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                (Nat.rawCast 143741772000 +
                                  (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast + 0)))))
                          (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                            (Mathlib.Meta.NormNum.IsInt.to_isNat
                              (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 143741772000))
                                (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 143741772000))
                                (Eq.refl (Int.ofNat 0))))
                            (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                              (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast + 0))))
                        (Mathlib.Tactic.Ring.Common.mul_congr
                          (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 36000000)))
                          (Mathlib.Tactic.Ring.Common.sub_congr
                            (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))
                            (Mathlib.Tactic.Ring.Common.atom_pf (p t) rfl
                              (Eq.mpr
                                (id
                                  (congrArg (fun _a => p t ^ Nat.rawCast 1 * Nat.rawCast 1 = p t ^ Nat.rawCast 1 * _a)
                                    (Eq.symm rfl)))
                                (Eq.refl (p t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                            (Mathlib.Tactic.Ring.Common.sub_pf
                              (Mathlib.Tactic.Ring.Common.neg_add
                                (Mathlib.Tactic.Ring.Common.neg_mul (p t) (Nat.rawCast 1)
                                  (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                    (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                      (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                      (Eq.refl (Int.negOfNat 1)))))
                                Mathlib.Tactic.Ring.Common.neg_zero)
                              (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                (p t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0))))
                          (Mathlib.Tactic.Ring.Common.add_mul
                            (Mathlib.Tactic.Ring.Common.mul_add
                              (Mathlib.Tactic.Ring.Common.mul_pf_right (p t) (Nat.rawCast 1)
                                (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                  (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                    (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 36000000))
                                    (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                    (Eq.refl (Int.negOfNat 36000000)))))
                              (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 36000000))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                (p t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast + 0)))
                            (Mathlib.Tactic.Ring.Common.zero_mul (p t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                              (p t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast + 0))))
                        (Mathlib.Tactic.Ring.Common.add_pf_add_lt
                          (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast)
                          (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                            (p t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast + 0))))
                      (Mathlib.Tactic.Ring.Common.mul_congr
                        (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 9)))
                        (Mathlib.Tactic.Ring.Common.sub_congr
                          (Mathlib.Tactic.Ring.Common.add_congr
                            (Mathlib.Tactic.Ring.Common.mul_congr
                              (Mathlib.Tactic.Ring.Common.mul_congr
                                (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                (Mathlib.Tactic.Ring.Common.add_mul
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                      (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 3992827) (Eq.refl 3992827)))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 1))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero (Nat.rawCast 3992827 + 0)))
                                  (Mathlib.Tactic.Ring.Common.zero_mul (Nat.rawCast 3992827 + 0))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero (Nat.rawCast 3992827 + 0))))
                              (Mathlib.Tactic.Ring.Common.mul_congr
                                (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                (Mathlib.Tactic.Ring.Common.atom_pf (cw t) rfl
                                  (Eq.mpr
                                    (id
                                      (congrArg
                                        (fun _a => cw t ^ Nat.rawCast 1 * Nat.rawCast 1 = cw t ^ Nat.rawCast 1 * _a)
                                        (Eq.symm rfl)))
                                    (Eq.refl (cw t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                (Mathlib.Tactic.Ring.Common.add_mul
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right (cw t) (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 1))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 1))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (cw t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0)))
                                  (Mathlib.Tactic.Ring.Common.zero_mul (cw t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (cw t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))))
                              (Mathlib.Tactic.Ring.Common.add_mul
                                (Mathlib.Tactic.Ring.Common.mul_add
                                  (Mathlib.Tactic.Ring.Common.mul_pf_right (cw t) (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                      (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 3992827)
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 3992827))))
                                  (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 3992827))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 + 0)))
                                (Mathlib.Tactic.Ring.Common.zero_mul (cw t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 + 0))))
                            (Mathlib.Tactic.Ring.Common.mul_congr
                              (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)))
                              (Mathlib.Tactic.Ring.Common.atom_pf (p t) rfl
                                (Eq.mpr
                                  (id
                                    (congrArg (fun _a => p t ^ Nat.rawCast 1 * Nat.rawCast 1 = p t ^ Nat.rawCast 1 * _a)
                                      (Eq.symm rfl)))
                                  (Eq.refl (p t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                              (Mathlib.Tactic.Ring.Common.add_mul
                                (Mathlib.Tactic.Ring.Common.mul_add
                                  (Mathlib.Tactic.Ring.Common.mul_pf_right (p t) (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                      (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000000)
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 4000000))))
                                  (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 4000000))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0)))
                                (Mathlib.Tactic.Ring.Common.zero_mul (p t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0))))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_lt (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827)
                              (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0))))
                          (Mathlib.Tactic.Ring.Common.mul_congr
                            (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)))
                            (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))
                            (Mathlib.Tactic.Ring.Common.add_mul
                              (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 4000000))
                              (Mathlib.Tactic.Ring.Common.zero_mul 0) (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0)))
                          (Mathlib.Tactic.Ring.Common.sub_pf Mathlib.Tactic.Ring.Common.neg_zero
                            (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                              (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 +
                                (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0)))))
                        (Mathlib.Tactic.Ring.Common.add_mul
                          (Mathlib.Tactic.Ring.Common.mul_add
                            (Mathlib.Tactic.Ring.Common.mul_pf_right (cw t) (Nat.rawCast 1)
                              (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                  (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9) (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 3992827)
                                  (Eq.refl 35935443))))
                            (Mathlib.Tactic.Ring.Common.mul_add
                              (Mathlib.Tactic.Ring.Common.mul_pf_right (p t) (Nat.rawCast 1)
                                (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                  (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9)
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000000) (Eq.refl 36000000))))
                              (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 9))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                (p t ^ Nat.rawCast 1 * Nat.rawCast 36000000 + 0)))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_lt (cw t ^ Nat.rawCast 1 * Nat.rawCast 35935443)
                              (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                (p t ^ Nat.rawCast 1 * Nat.rawCast 36000000 + 0))))
                          (Mathlib.Tactic.Ring.Common.zero_mul
                            (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 +
                              (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0)))
                          (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                            (cw t ^ Nat.rawCast 1 * Nat.rawCast 35935443 +
                              (p t ^ Nat.rawCast 1 * Nat.rawCast 36000000 + 0)))))
                      (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                        (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero (cw t) (Nat.rawCast 1)
                          (Mathlib.Meta.NormNum.IsInt.to_isNat
                            (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                              (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 35935443))
                              (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 35935443))
                              (Eq.refl (Int.ofNat 0)))))
                        (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                          (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero (p t) (Nat.rawCast 1)
                            (Mathlib.Meta.NormNum.IsInt.to_isNat
                              (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 36000000))
                                (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 36000000))
                                (Eq.refl (Int.ofNat 0)))))
                          (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0))))
                    (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))))
                (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
                  (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
                    (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
                      (Mathlib.Tactic.Linarith.add_neg
                        (Mathlib.Tactic.Linarith.mul_neg (Mathlib.Tactic.Linarith.sub_neg_of_lt hn)
                          (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                            (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 798565400000)) (Eq.refl false)))
                        (Mathlib.Tactic.Linarith.mul_neg
                          (Eq.mp
                            (congrArg (fun _a => _a < 0)
                              (Mathlib.Tactic.CancelDenoms.derive_trans
                                (Eq.trans
                                  (congrArg (HSub.hSub saltMoles)
                                    (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                      (Mathlib.Meta.NormNum.isNNRat_ofScientific_of_true
                                        (Mathlib.Meta.NormNum.isNNRat_nnratCast
                                          (Mathlib.Meta.NormNum.isNNRat_divNat (Mathlib.Meta.NormNum.IsNat.raw_refl 18)
                                            (Mathlib.Meta.NormNum.isNat_pow (Eq.refl HPow.hPow)
                                              (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 10))
                                              (Mathlib.Meta.NormNum.IsNat.raw_refl 2)
                                              (Mathlib.Meta.NormNum.IsNatPowT.run Mathlib.Meta.NormNum.IsNatPowT.bit0))
                                            (Mathlib.Meta.NormNum.isNNRat_div
                                              (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                  (Mathlib.Meta.NormNum.isNat_natCast 18 18
                                                    (Mathlib.Meta.NormNum.IsNat.raw_refl 18)))
                                                (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                  (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                    (Mathlib.Meta.NormNum.isNat_natCast 100 100
                                                      (Mathlib.Meta.NormNum.IsNat.raw_refl 100))))
                                                (Eq.refl (Nat.mul 18 1)) (Eq.refl 100))))))
                                      (Eq.refl 9) (Eq.refl 50)))
                                  (congrArg (HSub.hSub saltMoles)
                                    (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                      (Mathlib.Meta.NormNum.isNNRat_div
                                        (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                            (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 9)))
                                          (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                            (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                              (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50))))
                                          (Eq.refl (Nat.mul 9 1)) (Eq.refl 50)))
                                      (Eq.refl 9) (Eq.refl 50))))
                                (Mathlib.Tactic.CancelDenoms.sub_subst rfl
                                  (Mathlib.Tactic.CancelDenoms.div_subst rfl
                                    (Mathlib.Meta.NormNum.isNat_eq_true
                                      (Mathlib.Meta.NormNum.IsNNRat.to_isNat
                                        (Mathlib.Meta.NormNum.isNNRat_div
                                          (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                            (Mathlib.Meta.NormNum.IsNNRat.to_isNat
                                              (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)))
                                                (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                  (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50))))
                                                (Eq.refl (Nat.mul 50 1)) (Eq.refl 50))))))
                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                    (Mathlib.Meta.NormNum.isNat_eq_true
                                      (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one)
                                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)) (Eq.refl 50))
                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)))))))
                            (Mathlib.Tactic.Linarith.mul_neg (Mathlib.Tactic.Linarith.sub_neg_of_lt hnhi)
                              (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                                (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)) (Eq.refl false))))
                          (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                            (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 15971308000)) (Eq.refl false))))
                      (Mathlib.Tactic.Linarith.mul_nonpos (Mathlib.Tactic.Linarith.sub_nonpos_of_le hcw)
                        (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                          (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 35935443)) (Eq.refl false))))
                    (Mathlib.Tactic.Linarith.mul_nonpos (Mathlib.Tactic.Linarith.sub_nonpos_of_le hp)
                      (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 36000000)) (Eq.refl false))))
                  (Mathlib.Tactic.Linarith.mul_nonpos
                    (Eq.mp
                      (congrArg (fun _a => _a ≤ 0)
                        (Mathlib.Tactic.CancelDenoms.derive_trans
                          (Eq.trans
                            (congrFun'
                              (congrArg HSub.hSub
                                (Eq.trans
                                  (congrFun'
                                    (congrArg HAdd.hAdd
                                      (Eq.trans
                                        (congrFun'
                                          (congrArg HMul.hMul
                                            (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                              (Mathlib.Meta.NormNum.isNNRat_ofScientific_of_true
                                                (Mathlib.Meta.NormNum.isNNRat_nnratCast
                                                  (Mathlib.Meta.NormNum.isNNRat_divNat
                                                    (Mathlib.Meta.NormNum.IsNat.raw_refl 99820675)
                                                    (Mathlib.Meta.NormNum.isNat_pow (Eq.refl HPow.hPow)
                                                      (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 10))
                                                      (Mathlib.Meta.NormNum.IsNat.raw_refl 8)
                                                      (Mathlib.Meta.NormNum.IsNatPowT.run
                                                        (Mathlib.Meta.NormNum.IsNatPowT.trans
                                                          (Mathlib.Meta.NormNum.IsNatPowT.trans
                                                            Mathlib.Meta.NormNum.IsNatPowT.bit0
                                                            Mathlib.Meta.NormNum.IsNatPowT.bit0)
                                                          Mathlib.Meta.NormNum.IsNatPowT.bit0)))
                                                    (Mathlib.Meta.NormNum.isNNRat_div
                                                      (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                        (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                          (Mathlib.Meta.NormNum.isNat_natCast 99820675 99820675
                                                            (Mathlib.Meta.NormNum.IsNat.raw_refl 99820675)))
                                                        (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                          (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                            (Mathlib.Meta.NormNum.isNat_natCast 100000000 100000000
                                                              (Mathlib.Meta.NormNum.IsNat.raw_refl 100000000))))
                                                        (Eq.refl (Nat.mul 99820675 1)) (Eq.refl 100000000))))))
                                              (Eq.refl 3992827) (Eq.refl 4000000)))
                                          (cw t))
                                        (congrFun'
                                          (congrArg HMul.hMul
                                            (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                              (Mathlib.Meta.NormNum.isNNRat_div
                                                (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                  (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                                  (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                    (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                                  (Eq.refl (Nat.mul 3992827 1)) (Eq.refl 4000000)))
                                              (Eq.refl 3992827) (Eq.refl 4000000)))
                                          (cw t))))
                                    (p t))
                                  (congrFun'
                                    (congrArg HAdd.hAdd
                                      (congrFun'
                                        (congrArg HMul.hMul
                                          (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                            (Mathlib.Meta.NormNum.isNNRat_div
                                              (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                                (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                  (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                                (Eq.refl (Nat.mul 3992827 1)) (Eq.refl 4000000)))
                                            (Eq.refl 3992827) (Eq.refl 4000000)))
                                        (cw t)))
                                    (p t))))
                              0)
                            (congrFun'
                              (congrArg HSub.hSub
                                (congrFun'
                                  (congrArg HAdd.hAdd
                                    (congrFun'
                                      (congrArg HMul.hMul
                                        (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                          (Mathlib.Meta.NormNum.isNNRat_div
                                            (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                              (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                              (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                              (Eq.refl (Nat.mul 3992827 1)) (Eq.refl 4000000)))
                                          (Eq.refl 3992827) (Eq.refl 4000000)))
                                      (cw t)))
                                  (p t)))
                              0))
                          (Mathlib.Tactic.CancelDenoms.sub_subst
                            (Mathlib.Tactic.CancelDenoms.add_subst
                              (Mathlib.Tactic.CancelDenoms.mul_subst
                                (Mathlib.Tactic.CancelDenoms.div_subst rfl
                                  (Mathlib.Meta.NormNum.isNat_eq_true
                                    (Mathlib.Meta.NormNum.IsNNRat.to_isNat
                                      (Mathlib.Meta.NormNum.isNNRat_div
                                        (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                          (Mathlib.Meta.NormNum.IsNNRat.to_isNat
                                            (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                              (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)))
                                              (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                              (Eq.refl (Nat.mul 4000000 1)) (Eq.refl 4000000))))))
                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                  (Mathlib.Meta.NormNum.isNat_eq_true
                                    (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one)
                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)) (Eq.refl 4000000))
                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                rfl
                                (Mathlib.Meta.NormNum.isNat_eq_true
                                  (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))
                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one) (Eq.refl 4000000))
                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                              rfl)
                            rfl)))
                      (Mathlib.Tactic.Linarith.mul_nonpos (Mathlib.Tactic.Linarith.sub_nonpos_of_le a)
                        (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                          (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)) (Eq.refl false))))
                    (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 9)) (Eq.refl false))))),
          lt_of_not_ge fun a =>
            Mathlib.Tactic.Linarith.lt_irrefl
              (Eq.mp
                (congrArg (fun _a => _a < 0)
                  (Mathlib.Tactic.Ring.of_eq
                    (Mathlib.Tactic.Ring.Common.add_congr
                      (Mathlib.Tactic.Ring.Common.add_congr
                        (Mathlib.Tactic.Ring.Common.add_congr
                          (Mathlib.Tactic.Ring.Common.add_congr
                            (Mathlib.Tactic.Ring.Common.add_congr
                              (Mathlib.Tactic.Ring.Common.mul_congr
                                (Mathlib.Tactic.Ring.cast_pos
                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 794965400000)))
                                (Mathlib.Tactic.Ring.Common.sub_congr
                                  (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))
                                  (Mathlib.Tactic.Ring.Common.atom_pf saltMoles rfl
                                    (Eq.mpr
                                      (id
                                        (congrArg
                                          (fun _a =>
                                            saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 = saltMoles ^ Nat.rawCast 1 * _a)
                                          (Eq.symm rfl)))
                                      (Eq.refl (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                  (Mathlib.Tactic.Ring.Common.sub_pf
                                    (Mathlib.Tactic.Ring.Common.neg_add
                                      (Mathlib.Tactic.Ring.Common.neg_mul saltMoles (Nat.rawCast 1)
                                        (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                          (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                            (Mathlib.Meta.NormNum.IsNat.to_isInt
                                              (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                            (Eq.refl (Int.negOfNat 1)))))
                                      Mathlib.Tactic.Ring.Common.neg_zero)
                                    (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                      (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0))))
                                (Mathlib.Tactic.Ring.Common.add_mul
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                        (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.to_isInt
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 794965400000))
                                          (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                          (Eq.refl (Int.negOfNat 794965400000)))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 794965400000))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 794965400000).rawCast + 0)))
                                  (Mathlib.Tactic.Ring.Common.zero_mul
                                    (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 794965400000).rawCast + 0))))
                              (Mathlib.Tactic.Ring.Common.mul_congr
                                (Mathlib.Tactic.Ring.cast_pos
                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 15971308000)))
                                (Mathlib.Tactic.Ring.Common.sub_congr
                                  (Mathlib.Tactic.Ring.Common.mul_congr
                                    (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)))
                                    (Mathlib.Tactic.Ring.Common.atom_pf saltMoles rfl
                                      (Eq.mpr
                                        (id
                                          (congrArg
                                            (fun _a =>
                                              saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 =
                                                saltMoles ^ Nat.rawCast 1 * _a)
                                            (Eq.symm rfl)))
                                        (Eq.refl (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                    (Mathlib.Tactic.Ring.Common.add_mul
                                      (Mathlib.Tactic.Ring.Common.mul_add
                                        (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                          (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                            (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                              (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 50)
                                              (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 50))))
                                        (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 50))
                                        (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                          (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 50 + 0)))
                                      (Mathlib.Tactic.Ring.Common.zero_mul
                                        (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                      (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                        (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 50 + 0))))
                                  (Mathlib.Tactic.Ring.Common.mul_congr
                                    (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                    (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 9)))
                                    (Mathlib.Tactic.Ring.Common.add_mul
                                      (Mathlib.Tactic.Ring.Common.mul_add
                                        (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                          (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9) (Eq.refl 9)))
                                        (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 1))
                                        (Mathlib.Tactic.Ring.Common.add_pf_add_zero (Nat.rawCast 9 + 0)))
                                      (Mathlib.Tactic.Ring.Common.zero_mul (Nat.rawCast 9 + 0))
                                      (Mathlib.Tactic.Ring.Common.add_pf_add_zero (Nat.rawCast 9 + 0))))
                                  (Mathlib.Tactic.Ring.Common.sub_pf
                                    (Mathlib.Tactic.Ring.Common.neg_add
                                      (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                        (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                          (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9))
                                          (Eq.refl (Int.negOfNat 9))))
                                      Mathlib.Tactic.Ring.Common.neg_zero)
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_gt (Int.negOfNat 9).rawCast
                                      (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                        (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 50 + 0)))))
                                (Mathlib.Tactic.Ring.Common.add_mul
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                      (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.IsNat.to_isInt
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 15971308000))
                                        (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 9))
                                        (Eq.refl (Int.negOfNat 143741772000))))
                                    (Mathlib.Tactic.Ring.Common.mul_add
                                      (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                        (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                          (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 15971308000)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 50) (Eq.refl 798565400000))))
                                      (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 15971308000))
                                      (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                        (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 798565400000 + 0)))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_lt (Int.negOfNat 143741772000).rawCast
                                      (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                        (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 798565400000 + 0))))
                                  (Mathlib.Tactic.Ring.Common.zero_mul
                                    ((Int.negOfNat 9).rawCast + (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 50 + 0)))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    ((Int.negOfNat 143741772000).rawCast +
                                      (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 798565400000 + 0)))))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_gt (Int.negOfNat 143741772000).rawCast
                                (Mathlib.Tactic.Ring.Common.add_pf_add_overlap
                                  (Mathlib.Tactic.Ring.Common.add_overlap_pf saltMoles (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                      (Mathlib.Meta.NormNum.IsInt.to_isNat
                                        (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                          (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 794965400000))
                                          (Mathlib.Meta.NormNum.IsNat.to_isInt
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 798565400000))
                                          (Eq.refl (Int.ofNat 3600000000))))))
                                  (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0))))
                            (Mathlib.Tactic.Ring.Common.mul_congr
                              (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 35935443)))
                              (Mathlib.Tactic.Ring.Common.sub_congr
                                (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000)))
                                (Mathlib.Tactic.Ring.Common.atom_pf (cw t) rfl
                                  (Eq.mpr
                                    (id
                                      (congrArg
                                        (fun _a => cw t ^ Nat.rawCast 1 * Nat.rawCast 1 = cw t ^ Nat.rawCast 1 * _a)
                                        (Eq.symm rfl)))
                                    (Eq.refl (cw t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                (Mathlib.Tactic.Ring.Common.sub_pf
                                  (Mathlib.Tactic.Ring.Common.neg_add
                                    (Mathlib.Tactic.Ring.Common.neg_mul (cw t) (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                        (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                          (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                          (Eq.refl (Int.negOfNat 1)))))
                                    Mathlib.Tactic.Ring.Common.neg_zero)
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_lt (Nat.rawCast 4000)
                                    (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                      (cw t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0)))))
                              (Mathlib.Tactic.Ring.Common.add_mul
                                (Mathlib.Tactic.Ring.Common.mul_add
                                  (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                    (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                      (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 35935443)
                                      (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000) (Eq.refl 143741772000)))
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right (cw t) (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                        (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.to_isInt
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 35935443))
                                          (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                          (Eq.refl (Int.negOfNat 35935443)))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 35935443))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast + 0)))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_lt (Nat.rawCast 143741772000)
                                    (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                      (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast + 0))))
                                (Mathlib.Tactic.Ring.Common.zero_mul
                                  (Nat.rawCast 4000 + (cw t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0)))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (Nat.rawCast 143741772000 +
                                    (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast + 0)))))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                              (Mathlib.Meta.NormNum.IsInt.to_isNat
                                (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                  (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 143741772000))
                                  (Mathlib.Meta.NormNum.IsNat.to_isInt
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 143741772000))
                                  (Eq.refl (Int.ofNat 0))))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_lt
                                (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 3600000000)
                                (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                  (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast + 0)))))
                          (Mathlib.Tactic.Ring.Common.mul_congr
                            (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 36000000)))
                            (Mathlib.Tactic.Ring.Common.sub_congr
                              (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))
                              (Mathlib.Tactic.Ring.Common.atom_pf (p t) rfl
                                (Eq.mpr
                                  (id
                                    (congrArg (fun _a => p t ^ Nat.rawCast 1 * Nat.rawCast 1 = p t ^ Nat.rawCast 1 * _a)
                                      (Eq.symm rfl)))
                                  (Eq.refl (p t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                              (Mathlib.Tactic.Ring.Common.sub_pf
                                (Mathlib.Tactic.Ring.Common.neg_add
                                  (Mathlib.Tactic.Ring.Common.neg_mul (p t) (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                      (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                        (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                        (Eq.refl (Int.negOfNat 1)))))
                                  Mathlib.Tactic.Ring.Common.neg_zero)
                                (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                  (p t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0))))
                            (Mathlib.Tactic.Ring.Common.add_mul
                              (Mathlib.Tactic.Ring.Common.mul_add
                                (Mathlib.Tactic.Ring.Common.mul_pf_right (p t) (Nat.rawCast 1)
                                  (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                    (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                      (Mathlib.Meta.NormNum.IsNat.to_isInt
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 36000000))
                                      (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                      (Eq.refl (Int.negOfNat 36000000)))))
                                (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 36000000))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (p t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast + 0)))
                              (Mathlib.Tactic.Ring.Common.zero_mul (p t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast + 0))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                (p t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast + 0))))
                          (Mathlib.Tactic.Ring.Common.add_pf_add_lt (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 3600000000)
                            (Mathlib.Tactic.Ring.Common.add_pf_add_lt
                              (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast)
                              (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                (p t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast + 0)))))
                        (Mathlib.Tactic.Ring.Common.mul_congr
                          (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 36000000)))
                          (Mathlib.Tactic.Ring.Common.sub_congr
                            (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))
                            (Mathlib.Tactic.Ring.Common.mul_congr
                              (Mathlib.Tactic.Ring.Common.atom_pf saltMoles rfl
                                (Eq.mpr
                                  (id
                                    (congrArg
                                      (fun _a =>
                                        saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 = saltMoles ^ Nat.rawCast 1 * _a)
                                      (Eq.symm rfl)))
                                  (Eq.refl (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1))))
                              (Mathlib.Tactic.Ring.Common.add_congr
                                (Mathlib.Tactic.Ring.Common.atom_pf (apparentCapacity t) rfl
                                  (Eq.mpr
                                    (id
                                      (congrArg
                                        (fun _a =>
                                          apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 =
                                            apparentCapacity t ^ Nat.rawCast 1 * _a)
                                        (Eq.symm rfl)))
                                    (Eq.refl (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 100)))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_gt (Nat.rawCast 100)
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))))
                              (Mathlib.Tactic.Ring.Common.add_mul
                                (Mathlib.Tactic.Ring.Common.mul_add
                                  (Mathlib.Tactic.Ring.Common.mul_pf_left saltMoles (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                      (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                        (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 100) (Eq.refl 100))))
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_left saltMoles (Nat.rawCast 1)
                                      (Mathlib.Tactic.Ring.Common.mul_pf_right (apparentCapacity t) (Nat.rawCast 1)
                                        (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                          (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 1)))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (saltMoles ^ Nat.rawCast 1 *
                                          (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1) +
                                        0)))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_lt
                                    (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 100)
                                    (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                      (saltMoles ^ Nat.rawCast 1 *
                                          (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1) +
                                        0))))
                                (Mathlib.Tactic.Ring.Common.zero_mul
                                  (Nat.rawCast 100 + (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0)))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 100 +
                                    (saltMoles ^ Nat.rawCast 1 * (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1) +
                                      0)))))
                            (Mathlib.Tactic.Ring.Common.sub_pf
                              (Mathlib.Tactic.Ring.Common.neg_add
                                (Mathlib.Tactic.Ring.Common.neg_mul saltMoles (Nat.rawCast 1)
                                  (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                    (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                      (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 100))
                                      (Eq.refl (Int.negOfNat 100)))))
                                (Mathlib.Tactic.Ring.Common.neg_add
                                  (Mathlib.Tactic.Ring.Common.neg_mul saltMoles (Nat.rawCast 1)
                                    (Mathlib.Tactic.Ring.Common.neg_mul (apparentCapacity t) (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                        (Mathlib.Meta.NormNum.isInt_neg (Eq.refl Neg.neg)
                                          (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1))
                                          (Eq.refl (Int.negOfNat 1))))))
                                  Mathlib.Tactic.Ring.Common.neg_zero))
                              (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 100).rawCast +
                                  (saltMoles ^ Nat.rawCast 1 *
                                      (apparentCapacity t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast) +
                                    0)))))
                          (Mathlib.Tactic.Ring.Common.add_mul
                            (Mathlib.Tactic.Ring.Common.mul_add
                              (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                  (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                    (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 36000000))
                                    (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 100))
                                    (Eq.refl (Int.negOfNat 3600000000)))))
                              (Mathlib.Tactic.Ring.Common.mul_add
                                (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                  (Mathlib.Tactic.Ring.Common.mul_pf_right (apparentCapacity t) (Nat.rawCast 1)
                                    (Mathlib.Meta.NormNum.IsInt.to_raw_eq
                                      (Mathlib.Meta.NormNum.isInt_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.IsNat.to_isInt
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 36000000))
                                        (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 1))
                                        (Eq.refl (Int.negOfNat 36000000))))))
                                (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 36000000))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (saltMoles ^ Nat.rawCast 1 *
                                      (apparentCapacity t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast) +
                                    0)))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_lt
                                (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 3600000000).rawCast)
                                (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                  (saltMoles ^ Nat.rawCast 1 *
                                      (apparentCapacity t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast) +
                                    0))))
                            (Mathlib.Tactic.Ring.Common.zero_mul
                              (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 100).rawCast +
                                (saltMoles ^ Nat.rawCast 1 *
                                    (apparentCapacity t ^ Nat.rawCast 1 * (Int.negOfNat 1).rawCast) +
                                  0)))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                              (saltMoles ^ Nat.rawCast 1 * (Int.negOfNat 3600000000).rawCast +
                                (saltMoles ^ Nat.rawCast 1 *
                                    (apparentCapacity t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast) +
                                  0)))))
                        (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                          (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero saltMoles (Nat.rawCast 1)
                            (Mathlib.Meta.NormNum.IsInt.to_isNat
                              (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 3600000000))
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 3600000000))
                                (Eq.refl (Int.ofNat 0)))))
                          (Mathlib.Tactic.Ring.Common.add_pf_add_gt
                            (saltMoles ^ Nat.rawCast 1 *
                              (apparentCapacity t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                              (cw t ^ Nat.rawCast 1 * (Int.negOfNat 35935443).rawCast +
                                (p t ^ Nat.rawCast 1 * (Int.negOfNat 36000000).rawCast + 0))))))
                      (Mathlib.Tactic.Ring.Common.mul_congr
                        (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 9)))
                        (Mathlib.Tactic.Ring.Common.sub_congr
                          (Mathlib.Tactic.Ring.Common.add_congr
                            (Mathlib.Tactic.Ring.Common.add_congr
                              (Mathlib.Tactic.Ring.Common.mul_congr
                                (Mathlib.Tactic.Ring.Common.mul_congr
                                  (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                  (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                  (Mathlib.Tactic.Ring.Common.add_mul
                                    (Mathlib.Tactic.Ring.Common.mul_add
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 3992827) (Eq.refl 3992827)))
                                      (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 1))
                                      (Mathlib.Tactic.Ring.Common.add_pf_add_zero (Nat.rawCast 3992827 + 0)))
                                    (Mathlib.Tactic.Ring.Common.zero_mul (Nat.rawCast 3992827 + 0))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero (Nat.rawCast 3992827 + 0))))
                                (Mathlib.Tactic.Ring.Common.mul_congr
                                  (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                  (Mathlib.Tactic.Ring.Common.atom_pf (cw t) rfl
                                    (Eq.mpr
                                      (id
                                        (congrArg
                                          (fun _a => cw t ^ Nat.rawCast 1 * Nat.rawCast 1 = cw t ^ Nat.rawCast 1 * _a)
                                          (Eq.symm rfl)))
                                      (Eq.refl (cw t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                  (Mathlib.Tactic.Ring.Common.add_mul
                                    (Mathlib.Tactic.Ring.Common.mul_add
                                      (Mathlib.Tactic.Ring.Common.mul_pf_right (cw t) (Nat.rawCast 1)
                                        (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                          (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                            (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 1))))
                                      (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 1))
                                      (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                        (cw t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0)))
                                    (Mathlib.Tactic.Ring.Common.zero_mul (cw t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (cw t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))))
                                (Mathlib.Tactic.Ring.Common.add_mul
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right (cw t) (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 3992827)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 3992827))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 3992827))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 + 0)))
                                  (Mathlib.Tactic.Ring.Common.zero_mul (cw t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 + 0))))
                              (Mathlib.Tactic.Ring.Common.mul_congr
                                (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)))
                                (Mathlib.Tactic.Ring.Common.atom_pf (p t) rfl
                                  (Eq.mpr
                                    (id
                                      (congrArg
                                        (fun _a => p t ^ Nat.rawCast 1 * Nat.rawCast 1 = p t ^ Nat.rawCast 1 * _a)
                                        (Eq.symm rfl)))
                                    (Eq.refl (p t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                (Mathlib.Tactic.Ring.Common.add_mul
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right (p t) (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000000)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 4000000))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 4000000))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0)))
                                  (Mathlib.Tactic.Ring.Common.zero_mul (p t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0))))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_lt (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827)
                                (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                  (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0))))
                            (Mathlib.Tactic.Ring.Common.mul_congr
                              (Mathlib.Tactic.Ring.Common.mul_congr
                                (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                (Mathlib.Tactic.Ring.Common.atom_pf saltMoles rfl
                                  (Eq.mpr
                                    (id
                                      (congrArg
                                        (fun _a =>
                                          saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 = saltMoles ^ Nat.rawCast 1 * _a)
                                        (Eq.symm rfl)))
                                    (Eq.refl (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                (Mathlib.Tactic.Ring.Common.add_mul
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 1))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 1))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 + 0)))
                                  (Mathlib.Tactic.Ring.Common.zero_mul (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))))
                              (Mathlib.Tactic.Ring.Common.mul_congr
                                (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)))
                                (Mathlib.Tactic.Ring.Common.atom_pf (apparentCapacity t) rfl
                                  (Eq.mpr
                                    (id
                                      (congrArg
                                        (fun _a =>
                                          apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 =
                                            apparentCapacity t ^ Nat.rawCast 1 * _a)
                                        (Eq.symm rfl)))
                                    (Eq.refl (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1))))
                                (Mathlib.Tactic.Ring.Common.add_mul
                                  (Mathlib.Tactic.Ring.Common.mul_add
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right (apparentCapacity t) (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000000)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1) (Eq.refl 4000000))))
                                    (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 4000000))
                                    (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                      (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0)))
                                  (Mathlib.Tactic.Ring.Common.zero_mul
                                    (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 1 + 0))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0))))
                              (Mathlib.Tactic.Ring.Common.add_mul
                                (Mathlib.Tactic.Ring.Common.mul_add
                                  (Mathlib.Tactic.Ring.Common.mul_pf_left saltMoles (Nat.rawCast 1)
                                    (Mathlib.Tactic.Ring.Common.mul_pf_right (apparentCapacity t) (Nat.rawCast 1)
                                      (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 1)
                                          (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000000) (Eq.refl 4000000)))))
                                  (Mathlib.Tactic.Ring.Common.mul_zero (saltMoles ^ Nat.rawCast 1 * Nat.rawCast 1))
                                  (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                    (saltMoles ^ Nat.rawCast 1 *
                                        (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 4000000) +
                                      0)))
                                (Mathlib.Tactic.Ring.Common.zero_mul
                                  (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (saltMoles ^ Nat.rawCast 1 *
                                      (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 4000000) +
                                    0))))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_gt
                              (saltMoles ^ Nat.rawCast 1 * (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 4000000))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 +
                                  (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0)))))
                          (Mathlib.Tactic.Ring.Common.mul_congr
                            (Mathlib.Tactic.Ring.cast_pos (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)))
                            (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))
                            (Mathlib.Tactic.Ring.Common.add_mul
                              (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 4000000))
                              (Mathlib.Tactic.Ring.Common.zero_mul 0) (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0)))
                          (Mathlib.Tactic.Ring.Common.sub_pf Mathlib.Tactic.Ring.Common.neg_zero
                            (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                              (saltMoles ^ Nat.rawCast 1 * (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 4000000) +
                                (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 +
                                  (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0))))))
                        (Mathlib.Tactic.Ring.Common.add_mul
                          (Mathlib.Tactic.Ring.Common.mul_add
                            (Mathlib.Tactic.Ring.Common.mul_pf_right saltMoles (Nat.rawCast 1)
                              (Mathlib.Tactic.Ring.Common.mul_pf_right (apparentCapacity t) (Nat.rawCast 1)
                                (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                  (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9)
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000000) (Eq.refl 36000000)))))
                            (Mathlib.Tactic.Ring.Common.mul_add
                              (Mathlib.Tactic.Ring.Common.mul_pf_right (cw t) (Nat.rawCast 1)
                                (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                  (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9)
                                    (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 3992827) (Eq.refl 35935443))))
                              (Mathlib.Tactic.Ring.Common.mul_add
                                (Mathlib.Tactic.Ring.Common.mul_pf_right (p t) (Nat.rawCast 1)
                                  (Mathlib.Meta.NormNum.IsNat.to_raw_eq
                                    (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                      (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 9)
                                      (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 4000000) (Eq.refl 36000000))))
                                (Mathlib.Tactic.Ring.Common.mul_zero (Nat.rawCast 9))
                                (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                                  (p t ^ Nat.rawCast 1 * Nat.rawCast 36000000 + 0)))
                              (Mathlib.Tactic.Ring.Common.add_pf_add_lt (cw t ^ Nat.rawCast 1 * Nat.rawCast 35935443)
                                (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                  (p t ^ Nat.rawCast 1 * Nat.rawCast 36000000 + 0))))
                            (Mathlib.Tactic.Ring.Common.add_pf_add_lt
                              (saltMoles ^ Nat.rawCast 1 * (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 36000000))
                              (Mathlib.Tactic.Ring.Common.add_pf_zero_add
                                (cw t ^ Nat.rawCast 1 * Nat.rawCast 35935443 +
                                  (p t ^ Nat.rawCast 1 * Nat.rawCast 36000000 + 0)))))
                          (Mathlib.Tactic.Ring.Common.zero_mul
                            (saltMoles ^ Nat.rawCast 1 * (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 4000000) +
                              (cw t ^ Nat.rawCast 1 * Nat.rawCast 3992827 +
                                (p t ^ Nat.rawCast 1 * Nat.rawCast 4000000 + 0))))
                          (Mathlib.Tactic.Ring.Common.add_pf_add_zero
                            (saltMoles ^ Nat.rawCast 1 * (apparentCapacity t ^ Nat.rawCast 1 * Nat.rawCast 36000000) +
                              (cw t ^ Nat.rawCast 1 * Nat.rawCast 35935443 +
                                (p t ^ Nat.rawCast 1 * Nat.rawCast 36000000 + 0))))))
                      (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                        (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero saltMoles (Nat.rawCast 1)
                          (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero (apparentCapacity t) (Nat.rawCast 1)
                            (Mathlib.Meta.NormNum.IsInt.to_isNat
                              (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 36000000))
                                (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 36000000))
                                (Eq.refl (Int.ofNat 0))))))
                        (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                          (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero (cw t) (Nat.rawCast 1)
                            (Mathlib.Meta.NormNum.IsInt.to_isNat
                              (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 35935443))
                                (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 35935443))
                                (Eq.refl (Int.ofNat 0)))))
                          (Mathlib.Tactic.Ring.Common.add_pf_add_overlap_zero
                            (Mathlib.Tactic.Ring.Common.add_overlap_pf_zero (p t) (Nat.rawCast 1)
                              (Mathlib.Meta.NormNum.IsInt.to_isNat
                                (Mathlib.Meta.NormNum.isInt_add (Eq.refl HAdd.hAdd)
                                  (Mathlib.Meta.NormNum.IsInt.of_raw ℝ (Int.negOfNat 36000000))
                                  (Mathlib.Meta.NormNum.IsNat.to_isInt (Mathlib.Meta.NormNum.IsNat.of_raw ℝ 36000000))
                                  (Eq.refl (Int.ofNat 0)))))
                            (Mathlib.Tactic.Ring.Common.add_pf_zero_add 0)))))
                    (Mathlib.Tactic.Ring.cast_zero (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero))))
                (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
                  (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
                    (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
                      (Mathlib.Tactic.Linarith.add_lt_of_neg_of_le
                        (Mathlib.Tactic.Linarith.add_neg
                          (Mathlib.Tactic.Linarith.mul_neg (Mathlib.Tactic.Linarith.sub_neg_of_lt hn)
                            (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                              (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 794965400000)) (Eq.refl false)))
                          (Mathlib.Tactic.Linarith.mul_neg
                            (Eq.mp
                              (congrArg (fun _a => _a < 0)
                                (Mathlib.Tactic.CancelDenoms.derive_trans
                                  (Eq.trans
                                    (congrArg (HSub.hSub saltMoles)
                                      (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                        (Mathlib.Meta.NormNum.isNNRat_ofScientific_of_true
                                          (Mathlib.Meta.NormNum.isNNRat_nnratCast
                                            (Mathlib.Meta.NormNum.isNNRat_divNat
                                              (Mathlib.Meta.NormNum.IsNat.raw_refl 18)
                                              (Mathlib.Meta.NormNum.isNat_pow (Eq.refl HPow.hPow)
                                                (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 10))
                                                (Mathlib.Meta.NormNum.IsNat.raw_refl 2)
                                                (Mathlib.Meta.NormNum.IsNatPowT.run
                                                  Mathlib.Meta.NormNum.IsNatPowT.bit0))
                                              (Mathlib.Meta.NormNum.isNNRat_div
                                                (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                  (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                    (Mathlib.Meta.NormNum.isNat_natCast 18 18
                                                      (Mathlib.Meta.NormNum.IsNat.raw_refl 18)))
                                                  (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                    (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                      (Mathlib.Meta.NormNum.isNat_natCast 100 100
                                                        (Mathlib.Meta.NormNum.IsNat.raw_refl 100))))
                                                  (Eq.refl (Nat.mul 18 1)) (Eq.refl 100))))))
                                        (Eq.refl 9) (Eq.refl 50)))
                                    (congrArg (HSub.hSub saltMoles)
                                      (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                        (Mathlib.Meta.NormNum.isNNRat_div
                                          (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                            (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                              (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 9)))
                                            (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                              (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50))))
                                            (Eq.refl (Nat.mul 9 1)) (Eq.refl 50)))
                                        (Eq.refl 9) (Eq.refl 50))))
                                  (Mathlib.Tactic.CancelDenoms.sub_subst rfl
                                    (Mathlib.Tactic.CancelDenoms.div_subst rfl
                                      (Mathlib.Meta.NormNum.isNat_eq_true
                                        (Mathlib.Meta.NormNum.IsNNRat.to_isNat
                                          (Mathlib.Meta.NormNum.isNNRat_div
                                            (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                              (Mathlib.Meta.NormNum.IsNNRat.to_isNat
                                                (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                  (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)))
                                                  (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                    (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50))))
                                                  (Eq.refl (Nat.mul 50 1)) (Eq.refl 50))))))
                                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                      (Mathlib.Meta.NormNum.isNat_eq_true
                                        (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                          (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one)
                                          (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)) (Eq.refl 50))
                                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)))))))
                              (Mathlib.Tactic.Linarith.mul_neg (Mathlib.Tactic.Linarith.sub_neg_of_lt hnhi)
                                (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 50)) (Eq.refl false))))
                            (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                              (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 15971308000)) (Eq.refl false))))
                        (Mathlib.Tactic.Linarith.mul_nonpos (Mathlib.Tactic.Linarith.sub_nonpos_of_le hcw)
                          (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                            (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 35935443)) (Eq.refl false))))
                      (Mathlib.Tactic.Linarith.mul_nonpos (Mathlib.Tactic.Linarith.sub_nonpos_of_le hp)
                        (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                          (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 36000000)) (Eq.refl false))))
                    (Mathlib.Tactic.Linarith.mul_nonpos (Mathlib.Tactic.Linarith.sub_nonpos_of_le hbound)
                      (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 36000000)) (Eq.refl false))))
                  (Mathlib.Tactic.Linarith.mul_nonpos
                    (Eq.mp
                      (congrArg (fun _a => _a ≤ 0)
                        (Mathlib.Tactic.CancelDenoms.derive_trans
                          (Eq.trans
                            (congrFun'
                              (congrArg HSub.hSub
                                (Eq.trans
                                  (congrFun'
                                    (congrArg HAdd.hAdd
                                      (Eq.trans
                                        (congrFun'
                                          (congrArg HAdd.hAdd
                                            (Eq.trans
                                              (congrFun'
                                                (congrArg HMul.hMul
                                                  (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                                    (Mathlib.Meta.NormNum.isNNRat_ofScientific_of_true
                                                      (Mathlib.Meta.NormNum.isNNRat_nnratCast
                                                        (Mathlib.Meta.NormNum.isNNRat_divNat
                                                          (Mathlib.Meta.NormNum.IsNat.raw_refl 99820675)
                                                          (Mathlib.Meta.NormNum.isNat_pow (Eq.refl HPow.hPow)
                                                            (Mathlib.Meta.NormNum.isNat_ofNat ℕ (Eq.refl 10))
                                                            (Mathlib.Meta.NormNum.IsNat.raw_refl 8)
                                                            (Mathlib.Meta.NormNum.IsNatPowT.run
                                                              (Mathlib.Meta.NormNum.IsNatPowT.trans
                                                                (Mathlib.Meta.NormNum.IsNatPowT.trans
                                                                  Mathlib.Meta.NormNum.IsNatPowT.bit0
                                                                  Mathlib.Meta.NormNum.IsNatPowT.bit0)
                                                                Mathlib.Meta.NormNum.IsNatPowT.bit0)))
                                                          (Mathlib.Meta.NormNum.isNNRat_div
                                                            (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                              (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                                (Mathlib.Meta.NormNum.isNat_natCast 99820675 99820675
                                                                  (Mathlib.Meta.NormNum.IsNat.raw_refl 99820675)))
                                                              (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                                (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                                  (Mathlib.Meta.NormNum.isNat_natCast 100000000
                                                                    100000000
                                                                    (Mathlib.Meta.NormNum.IsNat.raw_refl 100000000))))
                                                              (Eq.refl (Nat.mul 99820675 1)) (Eq.refl 100000000))))))
                                                    (Eq.refl 3992827) (Eq.refl 4000000)))
                                                (cw t))
                                              (congrFun'
                                                (congrArg HMul.hMul
                                                  (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                                    (Mathlib.Meta.NormNum.isNNRat_div
                                                      (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                        (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                          (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                                        (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                          (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                            (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                                        (Eq.refl (Nat.mul 3992827 1)) (Eq.refl 4000000)))
                                                    (Eq.refl 3992827) (Eq.refl 4000000)))
                                                (cw t))))
                                          (p t))
                                        (congrFun'
                                          (congrArg HAdd.hAdd
                                            (congrFun'
                                              (congrArg HMul.hMul
                                                (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                                  (Mathlib.Meta.NormNum.isNNRat_div
                                                    (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                      (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                                      (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                        (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                          (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                                      (Eq.refl (Nat.mul 3992827 1)) (Eq.refl 4000000)))
                                                  (Eq.refl 3992827) (Eq.refl 4000000)))
                                              (cw t)))
                                          (p t))))
                                    (saltMoles * apparentCapacity t))
                                  (congrFun'
                                    (congrArg HAdd.hAdd
                                      (congrFun'
                                        (congrArg HAdd.hAdd
                                          (congrFun'
                                            (congrArg HMul.hMul
                                              (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                                (Mathlib.Meta.NormNum.isNNRat_div
                                                  (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                    (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                                    (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                      (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                                    (Eq.refl (Nat.mul 3992827 1)) (Eq.refl 4000000)))
                                                (Eq.refl 3992827) (Eq.refl 4000000)))
                                            (cw t)))
                                        (p t)))
                                    (saltMoles * apparentCapacity t))))
                              0)
                            (congrFun'
                              (congrArg HSub.hSub
                                (congrFun'
                                  (congrArg HAdd.hAdd
                                    (congrFun'
                                      (congrArg HAdd.hAdd
                                        (congrFun'
                                          (congrArg HMul.hMul
                                            (Mathlib.Meta.NormNum.IsNNRat.to_eq
                                              (Mathlib.Meta.NormNum.isNNRat_div
                                                (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                  (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 3992827)))
                                                  (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                    (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                                  (Eq.refl (Nat.mul 3992827 1)) (Eq.refl 4000000)))
                                              (Eq.refl 3992827) (Eq.refl 4000000)))
                                          (cw t)))
                                      (p t)))
                                  (saltMoles * apparentCapacity t)))
                              0))
                          (Mathlib.Tactic.CancelDenoms.sub_subst
                            (Mathlib.Tactic.CancelDenoms.add_subst
                              (Mathlib.Tactic.CancelDenoms.add_subst
                                (Mathlib.Tactic.CancelDenoms.mul_subst
                                  (Mathlib.Tactic.CancelDenoms.div_subst rfl
                                    (Mathlib.Meta.NormNum.isNat_eq_true
                                      (Mathlib.Meta.NormNum.IsNNRat.to_isNat
                                        (Mathlib.Meta.NormNum.isNNRat_div
                                          (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                            (Mathlib.Meta.NormNum.IsNNRat.to_isNat
                                              (Mathlib.Meta.NormNum.isNNRat_mul (Eq.refl HMul.hMul)
                                                (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)))
                                                (Mathlib.Meta.NormNum.isNNRat_inv_pos
                                                  (Mathlib.Meta.NormNum.IsNat.to_isNNRat
                                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                                (Eq.refl (Nat.mul 4000000 1)) (Eq.refl 4000000))))))
                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one))
                                    (Mathlib.Meta.NormNum.isNat_eq_true
                                      (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one)
                                        (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)) (Eq.refl 4000000))
                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                  rfl
                                  (Mathlib.Meta.NormNum.isNat_eq_true
                                    (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))
                                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one) (Eq.refl 4000000))
                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000))))
                                rfl)
                              (Mathlib.Tactic.CancelDenoms.mul_subst rfl rfl
                                (Mathlib.Meta.NormNum.isNat_eq_true
                                  (Mathlib.Meta.NormNum.isNat_mul (Eq.refl HMul.hMul)
                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_one)
                                    (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)) (Eq.refl 4000000))
                                  (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)))))
                            rfl)))
                      (Mathlib.Tactic.Linarith.mul_nonpos (Mathlib.Tactic.Linarith.sub_nonpos_of_le a)
                        (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                          (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 4000000)) (Eq.refl false))))
                    (Mathlib.Meta.NormNum.isNat_lt_true (Mathlib.Meta.NormNum.isNat_ofNat ℝ Nat.cast_zero)
                      (Mathlib.Meta.NormNum.isNat_ofNat ℝ (Eq.refl 9))
                      (Eq.refl false)))))⟩)) ⊢ (V 25 - U 25 - K) / saltMoles = 4.184 * (H + 87 + blend) + I VAS_END
VAS_LISTED
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean';s=open(p).read().replace('    · rw [ha]; field_simp','    · rw [ha]; field_simp <;> norm_num <;> ring');open(p,'w').write(s)\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json\""
}
shell output · exit 1 · failed
{
 "file": "/work/checks/b352fb73609c49c88d1352895ad763d1/submitted.lean",
 "conclusions": [
  "salt_timing_answer"
 ],
 "lean_exit": 0,
 "ok": false,
 "compiles_alone": true,
 "faithful": {
  "salt_timing_answer": false
 },
 "assumption_declarations": [
  "waterMass",
  "saltMoles",
  "blend",
  "calorimetricCurve",
  "apparentCapacity",
  "netPower",
  "totalTime",
  "waterCapacity"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "salt_timing_answer": {
   "original_sha256": "791f6662c1648f318cf8fc5d9c32d59aab41a02b338a3fa9fdbb587955843990",
   "extracted_sha256": "bc2047c131fc202a2a7fee4536b4cbfcf0040a3d8ce10d2ac5bb909d2bd49372"
  }
 },
 "dependency_faithful": {
  "saltMoles": true,
  "saltMoles._proof_1": true,
  "blend": true,
  "waterMass": true,
  "waterMass._proof_1": true,
  "waterCapacity": true,
  "apparentCapacity": true,
  "calorimetricCurve": true,
  "calorimetricCurve._proof_1": true,
  "calorimetricCurve._proof_2": true,
  "calorimetricCurve._proof_3": true,
  "calorimetricCurve._proof_4": true,
  "apparentCapacity._proof_1": true,
  "netPower": true,
  "totalTime": true
 },
 "dependency_identities": {
  "saltMoles": {
   "original_sha256": "827bccd82e2687317f9129d38e31997f9f2a83127c0fcf5ab6bf61c947140dd5",
   "extracted_sha256": "827bccd82e2687317f9129d38e31997f9f2a83127c0fcf5ab6bf61c947140dd5"
  },
  "saltMoles._proof_1": {
   "original_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e",
   "extracted_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e"
  },
  "blend": {
   "original_sha256": "0564ab882bd3f394420c6568a2a76aa7f9c3239ab5f7a2d7a22c57e50cf1192a",
   "extracted_sha256": "0564ab882bd3f394420c6568a2a76aa7f9c3239ab5f7a2d7a22c57e50cf1192a"
  },
  "waterMass": {
   "original_sha256": "54cdbd23ea81ba012ab9e6257436e9f54431a1eec79c5351523168154c27f078",
   "extracted_sha256": "54cdbd23ea81ba012ab9e6257436e9f54431a1eec79c5351523168154c27f078"
  },
  "waterMass._proof_1": {
   "original_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8",
   "extracted_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8"
  },
  "waterCapacity": {
   "original_sha256": "5ad429c7ec6f40440a6d5a145584438fb93a8b06f115cc9010f714bb382dd411",
   "extracted_sha256": "5ad429c7ec6f40440a6d5a145584438fb93a8b06f115cc9010f714bb382dd411"
  },
  "apparentCapacity": {
   "original_sha256": "ee228915221a930df961bddf28427bb24076b73fbab345b3a0d9cde5f78df92b",
   "extracted_sha256": "ee228915221a930df961bddf28427bb24076b73fbab345b3a0d9cde5f78df92b"
  },
  "calorimetricCurve": {
   "original_sha256": "4a4538aa3d3e0d4285eecafdac9d81b13ad47e8d382f5eb7964cac93e33ab328",
   "extracted_sha256": "4a4538aa3d3e0d4285eecafdac9d81b13ad47e8d382f5eb7964cac93e33ab328"
  },
  "calorimetricCurve._proof_1": {
   "original_sha256": "e72460529fc291789692b7a1d53e45b82e9c6684e8a3b5aa7472abea5e34b3a4",
   "extracted_sha256": "e72460529fc291789692b7a1d53e45b82e9c6684e8a3b5aa7472abea5e34b3a4"
  },
  "calorimetricCurve._proof_2": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "calorimetricCurve._proof_3": {
   "original_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae",
   "extracted_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae"
  },
  "calorimetricCurve._proof_4": {
   "original_sha256": "27a39ed7b1e9bbfe47c55794101d03a078de3a98d6b443fa3f39bbcb7f2437f9",
   "extracted_sha256": "27a39ed7b1e9bbfe47c55794101d03a078de3a98d6b443fa3f39bbcb7f2437f9"
  },
  "apparentCapacity._proof_1": {
   "original_sha256": "e7b45ed9c39659bc3b75357c46a1fa7efb15b8a0ab988e5dd0a24be646eb78f2",
   "extracted_sha256": "e7b45ed9c39659bc3b75357c46a1fa7efb15b8a0ab988e5dd0a24be646eb78f2"
  },
  "netPower": {
   "original_sha256": "3e22db0bc6aca59f93d188b3dab392fb5b33da7408ccc32ba5341d0ad4528095",
   "extracted_sha256": "3e22db0bc6aca59f93d188b3dab392fb5b33da7408ccc32ba5341d0ad4528095"
  },
  "totalTime": {
   "original_sha256": "ea4c6b4956d1767cf210da50bc45b391b0e0832264ed239f47d0d7f14eeb7b46",
   "extracted_sha256": "ea4c6b4956d1767cf210da50bc45b391b0e0832264ed239f47d0d7f14eeb7b46"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "salt_timing_answer": "\u2200 (U V cw p F G z : \u211d \u2192 \u211d) (K I H W k B0 B x : \u211d), \u21910 \u2264 I \u2192 \u2191923 \u2264 H \u2192 H \u2264 \u2191933 \u2192 V \u219125 - U \u219125 - K = saltMoles * (4.184 * (H + \u219187 + blend) + I) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, \u21914000 \u2264 cw t \u2227 \u21910 \u2264 p t) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, HasDerivAt U (waterCapacity cw p t) t) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) \u2192 \u219120 \u2264 B0 \u2192 B0 \u2264 B \u2192 B \u2264 \u2191100 \u2192 \u21910 < k \u2192 k * (B - \u219120) < W \u2192 (\u2200 (y : \u211d), V (z y) = U y + K) \u2192 (\u2200 y \u2208 Set.Icc (\u219120) B0, z y \u2208 Set.Icc (\u219119) B \u2227 DifferentiableAt \u211d z y) \u2192 (\u2200 t \u2208 Set.Icc (\u219119) B, HasDerivAt F (waterCapacity cw p t / netPower W k t) t \u2227 HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t) \u2192 x \u2208 Set.Icc (\u219120) B0 \u2192 z x < x \u2227 netPower W k (z x) - netPower W k x = k * (x - z x) \u2227 netPower W k x < netPower W k (z x) \u2227 totalTime F G z B \u219120 \u2264 totalTime F G z B x"
 },
 "extracted_file": "/work/checks/b352fb73609c49c88d1352895ad763d1/extracted.lean",
 "errors": []
}
{
  "ok": false,
  "check_complete": false,
  "reviewable": false,
  "verdict": "not_proved",
  "time": "2026-11-18T02:34:06.509920+00:00",
  "lean_exit": 0,
  "error": "independent extraction failed"
}
shell input
{
  "command": "/usr/bin/bash -lc \"sed -n '1,115p' /harness/src/vcs_extract.py; sed -n '130,245p' /harness/src/vcs_extract.py\""
}
shell output · exit 0
"""Extract statement dependencies and conclusions; independently compile and compare."""
import hashlib
import json
import os
from pathlib import Path
import re
import subprocess
import tempfile
import sys

import click

ROOT = Path(__file__).resolve().parents[1]
from vcs_lean import LEAN, LEANCHECKER, LISTER, listed  # noqa: E402

# Display text omits implicit arguments, types and sometimes whole subterms.
# Compare the complete kernel expressions instead. Binder names and metadata do
# not affect meaning; remove them so source positions and fresh binder names do
# not make an otherwise identical extraction fail. All constants, universe
# levels, implicit arguments and binder information remain in the identity.
IDENTITY = """
private partial def VAS_identityExpr : Lean.Expr → Lean.Expr
  | .mdata _ value => VAS_identityExpr value
  | .app fn arg => .app (VAS_identityExpr fn) (VAS_identityExpr arg)
  | .lam _ typ body info => .lam .anonymous (VAS_identityExpr typ) (VAS_identityExpr body) info
  | .forallE _ typ body info => .forallE .anonymous (VAS_identityExpr typ) (VAS_identityExpr body) info
  | .letE _ typ value body flag => .letE .anonymous (VAS_identityExpr typ) (VAS_identityExpr value) (VAS_identityExpr body) flag
  | .proj owner idx value => .proj owner idx (VAS_identityExpr value)
  | value => value

private def VAS_declarationIdentity (ci : Lean.ConstantInfo) : String :=
  let kind := match ci with
    | .axiomInfo _ => "axiom"
    | .defnInfo _ => "definition"
    | .thmInfo _ => "theorem"
    | .opaqueInfo _ => "opaque"
    | .quotInfo _ => "quotient"
    | .inductInfo info => s!"inductive {info.numParams} {info.numIndices} {reprStr info.ctors}"
    | .ctorInfo info => s!"constructor {info.induct} {info.cidx} {info.numParams} {info.numFields}"
    | .recInfo info => s!"recursor {info.numParams} {info.numIndices} {info.numMotives} {info.numMinors}"
  let value := match ci.value? with
    | some body => reprStr (VAS_identityExpr body)
    | none => "no value"
  s!"{kind}|levels={reprStr ci.levelParams}|type={reprStr (VAS_identityExpr ci.type)}|value={value}"
"""

REACH = """
open Lean Elab Command Meta in
run_cmd do
  let kenv := (← getEnv).checked.get
  let localSet : NameSet := kenv.constants.map₂.toList.foldl (fun s (n, _) => s.insert n) {}
  -- statements only: from each conclusion's type, through definitions' types and values
  let mut seen : NameSet := {}
  let mut todo : List Name := []
  for t in TARGETS do
    let some ci := kenv.find? t | throwError m!"no theorem {t}"
    todo := ci.type.getUsedConstants.toList ++ todo
    logInfo m!"VAS_CONCLUSION {t} : {← liftTermElabM <| ppExpr ci.type} VAS_END"
    logInfo m!"VAS_ORIGINAL_IDENTITY {t} : {reprStr (VAS_identityExpr ci.type)} VAS_END"
  while !todo.isEmpty do
    let n := todo.head!
    todo := todo.tail!
    if seen.contains n || !localSet.contains n then continue
    seen := seen.insert n
    let some ci := kenv.find? n | continue
    logInfo m!"VAS_DEPENDENCY_IDENTITY {n} : {VAS_declarationIdentity ci} VAS_END"
    let more := ci.type.getUsedConstants ++ (match ci with
      | .defnInfo v => v.value.getUsedConstants | .thmInfo v => v.value.getUsedConstants
      | .opaqueInfo v => v.value.getUsedConstants
      | .inductInfo v => v.ctors.toArray | .ctorInfo v => #[v.induct] | _ => #[])
    todo := more.toList ++ todo
    -- auxiliary constants (matchers, constructors, projections, equation lemmas) map to the nearest ancestor
    -- whose source range Lean recorded
    let mut m := n
    let mut r ← findDeclarationRanges? m
    while r.isNone && !m.isAnonymous do
      m := m.getPrefix
      r ← findDeclarationRanges? m
    match r with
    | some rg => logInfo m!"VAS_DECL {m} {rg.range.pos.line} {rg.range.endPos.line}"
    | none => logInfo m!"VAS_UNRANGED {n}"
  logInfo "VAS_REACHED"
"""

COMPARE = """
set_option format.width 100000 in
open Lean Elab Command Meta in
run_cmd do
  for n in NAMES do
    let some ci := (← getEnv).find? n | throwError m!"no {n}"
    let some v := ci.value? | throwError m!"no value {n}"
    logInfo m!"VAS_EXTRACTED {n} : {← liftTermElabM <| ppExpr v} VAS_END"
    logInfo m!"VAS_EXTRACTED_IDENTITY {n} : {reprStr (VAS_identityExpr v)} VAS_END"
  for n in DEPENDENCIES do
    let some ci := (← getEnv).find? n | throwError m!"missing extracted dependency {n}"
    logInfo m!"VAS_EXTRACTED_DEPENDENCY_IDENTITY {n} : {VAS_declarationIdentity ci} VAS_END"
"""


def run_lean(path):
    """Lean, then leanchecker on the compiled module (OT-1861): a nonzero status if either fails."""
    libs = sorted((ROOT / ".lake/packages").glob("*/.lake/build/lib/lean"))
    env = dict(os.environ, LEAN_PATH=":".join(map(str, libs)), LEAN_NUM_THREADS="1")
    with tempfile.TemporaryDirectory(prefix="vcs-olean-") as build:
        r = subprocess.run([LEAN, "-j1", f"--root={Path(path).resolve().parent}", "-o", str(Path(build) / "VasExtract.olean"), str(path)], cwd=ROOT,
                           env=env, capture_output=True, text=True, timeout=900)
        if r.returncode != 0:
            return r.returncode, r.stdout + r.stderr
        c = subprocess.run([LEANCHECKER, "VasExtract"], cwd=ROOT, capture_output=True, text=True, timeout=900,
                           env=dict(env, LEAN_PATH=env["LEAN_PATH"] + ":" + build,
                                    PATH=str(Path(LEAN).parent) + ":" + env.get("PATH", "")))
        note = f"\nleanchecker exit {c.returncode}\n{(c.stdout + c.stderr)[-1500:]}\n"
        return (0 if c.returncode == 0 else 10), r.stdout + r.stderr + note


    m = re.match(r"\s*(?:theorem|lemma)\s+" + re.escape(name) + r"\s*:(.*?):=", text, re.S)
    if not m:
        raise ValueError(f"cannot read the statement of {name}")
    return " ".join(m.group(1).split())


@click.command()
@click.argument("lean_file", type=click.Path(exists=True, dir_okay=False))
@click.option("--theorem", "theorems", multiple=True, required=True, help="a conclusion theorem (repeatable)")
@click.option("--out", "out_stem", required=True, help="output stem: writes <out>.lean and <out>.json")
def main(lean_file, theorems, out_stem):
    src = Path(lean_file).read_text()
    lines = src.splitlines()
    out = Path(out_stem)
    probe = out.with_name(out.name + ".probe.lean")
    targets = "[" + ", ".join(f"``{t}" for t in theorems) + "]"
    body = re.sub(r"(?m)^#print axioms.*\n?", "", src)
    # a file written by the current checker already ends with its own LISTER; drop it, the probe appends one
    head = next(ln for ln in LISTER.splitlines() if ln.strip())
    if head in body:
        body = body[:body.index(head)]
    probe.write_text(body + "\nset_option format.width 100000\n" + IDENTITY + REACH.replace("TARGETS", targets)
                     + LISTER.replace("ROOTS", targets))
    status, text = run_lean(probe)
    report = {"file": lean_file, "conclusions": list(theorems), "lean_exit": status}
    if status != 0 or "VAS_REACHED" not in text:
        report |= {"ok": False, "error": "the source did not compile with the extractor",
                   "errors": [ln for ln in text.splitlines() if ": error" in ln][:5]}
        print(json.dumps(report, indent=1))
        sys.exit(1)
    decls = {}
    for name, a, b in re.findall(r"VAS_DECL (\S+) (\d+) (\d+)", text):
        decls[name] = (int(a), int(b))
    unranged = re.findall(r"VAS_UNRANGED (\S+)", text)
    concl = dict(re.findall(r"VAS_CONCLUSION (\S+) : (.*?) VAS_END", text, re.S))
    original_identities = expression_identities(text, "VAS_ORIGINAL_IDENTITY")
    dependency_identities = expression_identities(text, "VAS_DEPENDENCY_IDENTITY")
    added = [a for a in listed(text) or [] if a["used"]]
    # the extracted file: imports, then each assumption's source in file order, inside its namespace. A range
    # inside another one (a structure's fields and constructor) is part of it and is not copied twice.
    imports = [ln for ln in lines if ln.startswith("import ")]
    spans = sorted(set(decls.values()))
    keep = [s for s in spans if not any(o != s and o[0] <= s[0] and s[1] <= o[1] for o in spans)]
    for x, y in zip(keep, keep[1:]):
        if y[0] <= x[1]:
            raise ValueError(f"overlapping declaration ranges {x} and {y}")
    owner = {}
    for name, rng in decls.items():
        if rng in keep and (rng not in owner or len(name) < len(owner[rng])):
            owner[rng] = name
    head = re.compile(r"^\s*(?:@\[[^\]]*\]\s*)?(?:noncomputable\s+|private\s+|protected\s+)*"
                      r"(?:def|theorem|lemma|abbrev|structure|inductive|class|axiom|instance|opaque)\s+([^\s:({\[]+)")
    # top-level `open X` lines of the source go along, in file order, so names resolve as they did there
    opens = [(i + 1, i + 1) for i, ln in enumerate(lines)
             if re.match(r"open\s+[\w.]+(\s+[\w.]+)*\s*$", ln) and not any(a <= i + 1 <= b for a, b in keep)]
    parts, current = [], None
    for rng in sorted(keep + opens):
        a, b = rng
        if rng in opens and rng not in owner:
            if current:
                parts.append(f"end {current}\n")
                current = None
            parts.append(lines[a - 1])
            continue
        name = owner[rng]
        short = next((m.group(1) for ln in lines[a - 1:b] if (m := head.match(ln))), None)
        if short is None or not (name == short or name.endswith("." + short)):
            raise ValueError(f"cannot match the source of {name} at lines {a}-{b}")
        ns = name[: -len(short) - 1] if name != short else ""
        if ns != current:
            if current:
                parts.append(f"end {current}\n")
            if ns:
                parts.append(f"namespace {ns}")
            current = ns
        parts.append("\n".join(lines[a - 1:b]) + "\n")
    if current:
        parts.append(f"end {current}\n")
    starts = {}
    for t in theorems:
        m = re.search(r"(?m)^\s*(?:theorem|lemma)\s+" + re.escape(t) + r"\b", src)
        starts[t] = src[:m.start()].count("\n") + 1 if m else None
    stmts = {t: statement_text(lines, starts[t], t) for t in theorems}
    conclusions = "".join(f"def conclusion_{t} : Prop := {stmts[t]}\n" for t in theorems)
    extracted = ("\n".join(imports) + "\n\n" + "\n".join(parts) + "\n\n"
                 "/-! Conclusions (statements of the proved theorems). -/\n" + conclusions)
    out.with_suffix(".lean").write_text(extracted)
    # step 5: the extracted file compiles alone, and its conclusions are the proved statements
    check = out.with_name(out.name + ".check.lean")
    names = "[" + ", ".join(f"``conclusion_{t}" for t in theorems) + "]"
    dependencies = "[" + ", ".join(f"``{name}" for name in dependency_identities) + "]"
    check.write_text(extracted + IDENTITY + COMPARE.replace("NAMES", names).replace("DEPENDENCIES", dependencies))
    status2, text2 = run_lean(check)
    extracted_identities = expression_identities(text2, "VAS_EXTRACTED_IDENTITY")
    same = {t: bool(original_identities.get(t)) and
            original_identities[t] == extracted_identities.get("conclusion_" + t)
            for t in theorems}
    extracted_dependencies = expression_identities(text2, "VAS_EXTRACTED_DEPENDENCY_IDENTITY")
    dependencies_same = {name: value == extracted_dependencies.get(name)
                         for name, value in dependency_identities.items()}
    identity_hashes = {
        t: {"original_sha256": hashlib.sha256(original_identities[t].encode()).hexdigest()
            if t in original_identities else None,
            "extracted_sha256": hashlib.sha256(extracted_identities["conclusion_" + t].encode()).hexdigest()
            if "conclusion_" + t in extracted_identities else None}
        for t in theorems}
    dependency_hashes = {
        name: {"original_sha256": hashlib.sha256(value.encode()).hexdigest(),
               "extracted_sha256": hashlib.sha256(extracted_dependencies[name].encode()).hexdigest()
               if name in extracted_dependencies else None}
        for name, value in dependency_identities.items()}
    report |= {"ok": status2 == 0 and all(same.values()) and all(dependencies_same.values())
               and set(dependency_identities) == set(extracted_dependencies) and not unranged,
               "compiles_alone": status2 == 0,
               "faithful": same, "assumption_declarations": [owner[r] for r in keep],
               "identity_method": "kernel-expression-repr-v1", "conclusion_identities": identity_hashes,
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/evidence/cycle9/inspect_extraction.py <<'PY'\nimport sys\nfrom pathlib import Path\nsys.path.insert(0,'/harness/src')\nimport vcs_extract\noriginal=vcs_extract.run_lean\ncounter=0\ndef capture(path):\n global counter\n counter+=1\n result=original(path)\n Path('/work/evidence/cycle9/identity-trace-'+str(counter)+'.txt').write_text(result[1])\n return result\nvcs_extract.run_lean=capture\nvcs_extract.main(['/work/Model.lean','--theorem','salt_timing_answer','--out','/work/evidence/cycle9/identity-inspection'],standalone_mode=False)\nPY\npython /work/evidence/cycle9/inspect_extraction.py > /work/evidence/cycle9/identity-inspection-result.txt 2>&1\""
}
assistant
The proof compiles and passes the kernel check, but extraction still reports a mismatch. I’m comparing the full elaborated statements to locate the difference. The scientific model and timing argument remain unchanged.
shell input
{
  "command": "/usr/bin/bash -lc 'ls -lh /work/evidence/cycle9/identity-trace-* 2>/dev/null'"
}
shell output · exit 0
-rw-r--r-- 1 1001 1001 296K Nov 18 02:35 /work/evidence/cycle9/identity-trace-1.txt
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'ls -lh /work/evidence/cycle9/identity-trace-*'"
}
shell output · exit 0
-rw-r--r-- 1 1001 1001 296K Nov 18 02:35 /work/evidence/cycle9/identity-trace-1.txt
-rw-r--r-- 1 1001 1001 229K Nov 18 02:35 /work/evidence/cycle9/identity-trace-2.txt
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport sys,difflib\nsys.path.insert(0,'/harness/src');from vcs_extract import expression_identities\nfrom pathlib import Path\na=list(expression_identities(Path('/work/evidence/cycle9/identity-trace-1.txt').read_text(),'VAS_ORIGINAL_IDENTITY').values())[0]\nb=list(expression_identities(Path('/work/evidence/cycle9/identity-trace-2.txt').read_text(),'VAS_EXTRACTED_IDENTITY').values())[0]\nprint('lengths',len(a),len(b))\nfor op,i,j,k,l in difflib.SequenceMatcher(None,a,b,autojunk=False).get_opcodes():\n if op\"'!='\"'equal':\n  print(op,'ORIGINAL',a[max(0,i-180):min(len(a),j+180)],'EXTRACTED',b[max(0,k-180):min(len(b),l+180)])\nPY\""
}
shell input
{
  "command": "/usr/bin/bash -lc \"python -u - <<'PY'\nimport sys\nsys.path.insert(0,'/harness/src');from vcs_extract import expression_identities\nfrom pathlib import Path\na=list(expression_identities(Path('/work/evidence/cycle9/identity-trace-1.txt').read_text(),'VAS_ORIGINAL_IDENTITY').values())[0]\nb=list(expression_identities(Path('/work/evidence/cycle9/identity-trace-2.txt').read_text(),'VAS_EXTRACTED_IDENTITY').values())[0]\nprint('lengths',len(a),len(b))\ni=next(i for i,(x,y) in enumerate(zip(a,b)) if x\"'!=y)\nprint('\"'first difference',i,'ORIGINAL',a[i-400:i+1600],'EXTRACTED',b[i-400:i+1600])\nPY\""
}
shell output · exit 0
lengths 56020 42056
first difference 14592 ORIGINAL o]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.denselyNormedField []))))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instPolynormableSpaceOfIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr. EXTRACTED o]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.denselyNormedField []))))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar 1))) (Lean.Expr.bvar 1)) (Lean.BinderInfo.default)) (Lean.BinderInfo.default)) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.const `Real []) (Lean.Expr.forallE Lean.Name.anonymous (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Membership.mem [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.const `Set [Lean.Level.zero]) (Lean.Expr.const `Real []))) (Lean.Expr.app (Lean.Expr.const `Set.instMembership [Lean.Level.zero]) (Lean.Expr.const `Real []))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Set.Icc [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.instPreorder [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.cast [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `OfNat.ofNat [Lean.Level.zero]) (Lean.Expr.const `Nat [])) (Lean.Expr.lit (Lean.Literal.natVal 19))) (Lean.Expr.app (Lean.Expr.const `instOfNatNat []) (Lean.Expr.lit (Lean.Literal.natVal 19)))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Nat.cast [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.instNatCast [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.con
shell input
{
  "command": "/usr/bin/bash -lc \"grep -n 'def HasDerivAt\\\\|abbrev HasDerivAt\\\\|HasDerivAt ' /harness/.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Basic.lean | head -12; grep -n 'continuousSMul\\\\|ContinuousSMul' /harness/.lake/packages/mathlib/Mathlib/Analysis/Normed/Field/Basic.lean | head -15; grep -n 'ContinuousSMul' /harness/.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Basic.lean | head -15\""
}
shell output · exit 0
grep: /harness/.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Basic.lean: No such file or directory
grep: /harness/.lake/packages/mathlib/Mathlib/Analysis/Normed/Field/Basic.lean: No such file or directory
grep: /harness/.lake/packages/mathlib/Mathlib/Analysis/Calculus/Deriv/Basic.lean: No such file or directory
shell output · exit 0
lengths 56020 42056
delete ORIGINAL xpr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Ex EXTRACTED xpr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.
delete ORIGINAL eal [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCom EXTRACTED  (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bv
insert ORIGINAL onst `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGr EXTRACTED ean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Ex
insert ORIGINAL st `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGrou EXTRACTED ean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.b
replace ORIGINAL t `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean. EXTRACTED .Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar
replace ORIGINAL MetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app ( EXTRACTED r.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar 1))
delete ORIGINAL e [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr EXTRACTED nst `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar 1))) 
replace ORIGINAL  (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lea EXTRACTED st `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar 1))) (Le
delete ORIGINAL r.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Sem EXTRACTED PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar 1))) (Lean
replace ORIGINAL .app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toMo EXTRACTED seudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar 1))) (Lean.Exp
delete ORIGINAL xpr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instPolynormableSpaceOfIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NonUnitalSeminormedRing.toSeminormedAddCommGroup [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `SeminormedCommRing.toNonUnitalSeminormedCommRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedCommRing.toSeminormedCommRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedCommRing [])))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toNormedSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])))))) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar 1))) (Lean.Expr.b EXTRACTED etricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `waterCapacity []) (Lean.Expr.bvar 19)) (Lean.Expr.bvar 18)) (Lean.Expr.bvar 1))) (Lean.Expr.b
delete ORIGINAL xpr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Ex EXTRACTED xpr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `
delete ORIGINAL eal [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCom EXTRACTED  (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hA
insert ORIGINAL onst `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGr EXTRACTED ean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.z
insert ORIGINAL st `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGrou EXTRACTED ean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero,
replace ORIGINAL t `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean. EXTRACTED .Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero, Le
replace ORIGINAL MetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app ( EXTRACTED r.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero, Lean.L
delete ORIGINAL e [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr EXTRACTED nst `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero, Lean.Lev
replace ORIGINAL  (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lea EXTRACTED st `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero, Lean.Level.
delete ORIGINAL r.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Sem EXTRACTED PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero, Lean.Level.ze
replace ORIGINAL .app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toMo EXTRACTED seudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero, Lean.Level.zero, 
delete ORIGINAL xpr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instPolynormableSpaceOfIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NonUnitalSeminormedRing.toSeminormedAddCommGroup [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `SeminormedCommRing.toNonUnitalSeminormedCommRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedCommRing.toSeminormedCommRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedCommRing [])))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toNormedSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])))))) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero, Lean.Level.zero, Lea EXTRACTED etricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 21)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HAdd.hAdd [Lean.Level.zero, Lean.Level.zero, Lea
delete ORIGINAL xpr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Ex EXTRACTED xpr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `
delete ORIGINAL eal [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCom EXTRACTED  (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hD
insert ORIGINAL onst `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGr EXTRACTED ean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.z
insert ORIGINAL st `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGrou EXTRACTED ean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero,
replace ORIGINAL t `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean. EXTRACTED .Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Le
replace ORIGINAL MetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app ( EXTRACTED r.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.L
delete ORIGINAL e [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr EXTRACTED nst `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Lev
replace ORIGINAL  (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lea EXTRACTED st `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.
delete ORIGINAL r.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Sem EXTRACTED PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.ze
replace ORIGINAL .app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toMo EXTRACTED seudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.zero, 
delete ORIGINAL xpr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instPolynormableSpaceOfIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NonUnitalSeminormedRing.toSeminormedAddCommGroup [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `SeminormedCommRing.toNonUnitalSeminormedCommRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedCommRing.toSeminormedCommRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedCommRing [])))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toNormedSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])))))) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.zero, Lea EXTRACTED etricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 26)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.zero, Lea
delete ORIGINAL xpr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Ex EXTRACTED xpr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `
delete ORIGINAL eal [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCom EXTRACTED  (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hD
insert ORIGINAL onst `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGr EXTRACTED ean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.z
insert ORIGINAL st `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGrou EXTRACTED ean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero,
replace ORIGINAL t `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean. EXTRACTED .Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Le
replace ORIGINAL MetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app ( EXTRACTED r.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.L
delete ORIGINAL e [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr EXTRACTED nst `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Lev
replace ORIGINAL  (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lea EXTRACTED st `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.
delete ORIGINAL r.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Sem EXTRACTED PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.ze
replace ORIGINAL .app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toMo EXTRACTED seudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.zero, 
delete ORIGINAL xpr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PolynormableSpace.continuousSMul [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instPolynormableSpaceOfIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.const `Real.instAddCommGroup [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semiring.toModule [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `CommSemiring.toSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Semifield.toCommSemiring [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `Field.toSemifield [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toField [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField []))))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `UniformSpace.toTopologicalSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `PseudoMetricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `instIsNormableSpace [Lean.Level.zero, Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NonUnitalSeminormedRing.toSeminormedAddCommGroup [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NonUnitalSeminormedCommRing.toNonUnitalSeminormedRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `SeminormedCommRing.toNonUnitalSeminormedCommRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedCommRing.toSeminormedCommRing [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedCommRing [])))))) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `NormedField.toNormedSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.normedField [])))))) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.zero, Lea EXTRACTED etricSpace.toUniformSpace [Lean.Level.zero]) (Lean.Expr.const `Real [])) (Lean.Expr.const `Real.pseudoMetricSpace [])))) (Lean.Expr.const `conclusion_salt_timing_answer._proof_1 [])) (Lean.Expr.bvar 25)) (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.app (Lean.Expr.const `HDiv.hDiv [Lean.Level.zero, Lean.Level.zero, Lea
shell input
{
  "command": "/usr/bin/bash -lc \"cat > /work/evidence/cycle9/TypeInspect.lean <<'EOF'\nimport Mathlib.Analysis.Calculus.Deriv.MeanValue\n#check @HasDerivAt\n#check @ContinuousSMul\n#check @Real.instContinuousSMul\n#check @NormedSpace.instContinuousSMul\n#check @NormedSpace.toContinuousSMul\n#check @PolynormableSpace.continuousSMul\n#check @IsScalarTower.toContinuousSMul\n#check @HasFDerivAt\n#print HasDerivAt\nEOF\nsource /work/lean-env.sh\n/opt/lean/bin/lean /work/evidence/cycle9/TypeInspect.lean > /work/evidence/cycle9/types.txt 2>&1\""
}
shell output · exit 1 · failed
shell input
{
  "command": "/usr/bin/bash -lc 'cat /work/evidence/cycle9/types.txt'"
}
shell output · exit 0
@HasDerivAt : {𝕜 : Type u_1} →
  [inst : NontriviallyNormedField 𝕜] →
    {F : Type u_2} →
      [inst_1 : AddCommGroup F] →
        [inst_2 : Module 𝕜 F] → [inst_3 : TopologicalSpace F] → [ContinuousSMul 𝕜 F] → (𝕜 → F) → F → 𝕜 → Prop
ContinuousSMul : (M : Type u_1) → (X : Type u_2) → [SMul M X] → [TopologicalSpace M] → [TopologicalSpace X] → Prop
/work/evidence/cycle9/TypeInspect.lean:4:8: error(lean.unknownIdentifier): Unknown constant `Real.instContinuousSMul`
/work/evidence/cycle9/TypeInspect.lean:5:8: error(lean.unknownIdentifier): Unknown constant `NormedSpace.instContinuousSMul`
/work/evidence/cycle9/TypeInspect.lean:6:8: error(lean.unknownIdentifier): Unknown constant `NormedSpace.toContinuousSMul`
PolynormableSpace.continuousSMul : ∀ (𝕜 : Type u_1) (E : Type u_2) [inst : NormedField 𝕜] [inst_1 : AddCommGroup E]
  [inst_2 : Module 𝕜 E] [inst_3 : TopologicalSpace E] [PolynormableSpace 𝕜 E], ContinuousSMul 𝕜 E
/work/evidence/cycle9/TypeInspect.lean:8:8: error(lean.unknownIdentifier): Unknown constant `IsScalarTower.toContinuousSMul`
@HasFDerivAt : {𝕜 : Type u_1} →
  [inst : NontriviallyNormedField 𝕜] →
    {E : Type u_2} →
      [inst_1 : AddCommGroup E] →
        [inst_2 : Module 𝕜 E] →
          [inst_3 : TopologicalSpace E] →
            {F : Type u_3} →
              [inst_4 : AddCommGroup F] →
                [inst_5 : Module 𝕜 F] → [inst_6 : TopologicalSpace F] → (E → F) → (E →L[𝕜] F) → E → Prop
def HasDerivAt.{u, v} : {𝕜 : Type u} →
  [inst : NontriviallyNormedField 𝕜] →
    {F : Type v} →
      [inst_1 : AddCommGroup F] →
        [inst_2 : Module 𝕜 F] → [inst_3 : TopologicalSpace F] → [ContinuousSMul 𝕜 F] → (𝕜 → F) → F → 𝕜 → Prop :=
fun {𝕜} [NontriviallyNormedField 𝕜] {F} [AddCommGroup F] [Module 𝕜 F] [TopologicalSpace F] [ContinuousSMul 𝕜 F] f f'
    x =>
  HasDerivAtFilter f f' (nhds x ×ˢ pure x)
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\np='/work/Model.lean';s=open(p).read();i=s.index('/- Scientific conclusion.')\ns=s[:i]+'''/- Technical library fact, proved rather than assumed. Naming this proof\n   prevents the extractor from replacing an implicit continuity proof by\n   a fresh auxiliary constant. It adds no physical premise. -/\nlemma real_scalar_continuity : ContinuousSMul ℝ ℝ := by infer_instance\n\n'''+s[i:]\ni=s.index('theorem salt_timing_answer :');j=s.index(' := by',i)\na=s[i:j].replace('HasDerivAt ', '@HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity ')\ns=s[:i]+a+s[j:];open(p,'w').write(s)\nPY\npython /harness/src/vcs_protocol.py tool check --manifest /work/candidate.json\""
}
assistant
The mismatch came from an implicit Lean continuity proof: extraction replaced it with a fresh auxiliary constant. I’ve named that library proof explicitly and rerun the harness. This is a technical change only; the physical assumptions and scientific conclusion are unchanged.
shell output · exit 0
{
 "file": "/work/checks/e19bacdc762e44f8bb76c4620e9c4221/submitted.lean",
 "conclusions": [
  "salt_timing_answer"
 ],
 "lean_exit": 0,
 "ok": true,
 "compiles_alone": true,
 "faithful": {
  "salt_timing_answer": true
 },
 "assumption_declarations": [
  "waterMass",
  "saltMoles",
  "blend",
  "calorimetricCurve",
  "apparentCapacity",
  "netPower",
  "totalTime",
  "waterCapacity",
  "real_scalar_continuity"
 ],
 "identity_method": "kernel-expression-repr-v1",
 "conclusion_identities": {
  "salt_timing_answer": {
   "original_sha256": "eea0f5a52b59f9246132f5903f12e0b471b3ab75ec9f5190d4bd51bf1e24a201",
   "extracted_sha256": "eea0f5a52b59f9246132f5903f12e0b471b3ab75ec9f5190d4bd51bf1e24a201"
  }
 },
 "dependency_faithful": {
  "saltMoles": true,
  "saltMoles._proof_1": true,
  "blend": true,
  "waterMass": true,
  "waterMass._proof_1": true,
  "real_scalar_continuity": true,
  "waterCapacity": true,
  "apparentCapacity": true,
  "calorimetricCurve": true,
  "calorimetricCurve._proof_1": true,
  "calorimetricCurve._proof_2": true,
  "calorimetricCurve._proof_3": true,
  "calorimetricCurve._proof_4": true,
  "apparentCapacity._proof_1": true,
  "netPower": true,
  "totalTime": true
 },
 "dependency_identities": {
  "saltMoles": {
   "original_sha256": "827bccd82e2687317f9129d38e31997f9f2a83127c0fcf5ab6bf61c947140dd5",
   "extracted_sha256": "827bccd82e2687317f9129d38e31997f9f2a83127c0fcf5ab6bf61c947140dd5"
  },
  "saltMoles._proof_1": {
   "original_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e",
   "extracted_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e"
  },
  "blend": {
   "original_sha256": "0564ab882bd3f394420c6568a2a76aa7f9c3239ab5f7a2d7a22c57e50cf1192a",
   "extracted_sha256": "0564ab882bd3f394420c6568a2a76aa7f9c3239ab5f7a2d7a22c57e50cf1192a"
  },
  "waterMass": {
   "original_sha256": "54cdbd23ea81ba012ab9e6257436e9f54431a1eec79c5351523168154c27f078",
   "extracted_sha256": "54cdbd23ea81ba012ab9e6257436e9f54431a1eec79c5351523168154c27f078"
  },
  "waterMass._proof_1": {
   "original_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8",
   "extracted_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8"
  },
  "real_scalar_continuity": {
   "original_sha256": "11472ac66ebf7ba9b8ae413c640c759d5b83f1c272f054e99ec50cb0a9eeadbf",
   "extracted_sha256": "11472ac66ebf7ba9b8ae413c640c759d5b83f1c272f054e99ec50cb0a9eeadbf"
  },
  "waterCapacity": {
   "original_sha256": "5ad429c7ec6f40440a6d5a145584438fb93a8b06f115cc9010f714bb382dd411",
   "extracted_sha256": "5ad429c7ec6f40440a6d5a145584438fb93a8b06f115cc9010f714bb382dd411"
  },
  "apparentCapacity": {
   "original_sha256": "ee228915221a930df961bddf28427bb24076b73fbab345b3a0d9cde5f78df92b",
   "extracted_sha256": "ee228915221a930df961bddf28427bb24076b73fbab345b3a0d9cde5f78df92b"
  },
  "calorimetricCurve": {
   "original_sha256": "4a4538aa3d3e0d4285eecafdac9d81b13ad47e8d382f5eb7964cac93e33ab328",
   "extracted_sha256": "4a4538aa3d3e0d4285eecafdac9d81b13ad47e8d382f5eb7964cac93e33ab328"
  },
  "calorimetricCurve._proof_1": {
   "original_sha256": "e72460529fc291789692b7a1d53e45b82e9c6684e8a3b5aa7472abea5e34b3a4",
   "extracted_sha256": "e72460529fc291789692b7a1d53e45b82e9c6684e8a3b5aa7472abea5e34b3a4"
  },
  "calorimetricCurve._proof_2": {
   "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
   "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
  },
  "calorimetricCurve._proof_3": {
   "original_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae",
   "extracted_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae"
  },
  "calorimetricCurve._proof_4": {
   "original_sha256": "27a39ed7b1e9bbfe47c55794101d03a078de3a98d6b443fa3f39bbcb7f2437f9",
   "extracted_sha256": "27a39ed7b1e9bbfe47c55794101d03a078de3a98d6b443fa3f39bbcb7f2437f9"
  },
  "apparentCapacity._proof_1": {
   "original_sha256": "e7b45ed9c39659bc3b75357c46a1fa7efb15b8a0ab988e5dd0a24be646eb78f2",
   "extracted_sha256": "e7b45ed9c39659bc3b75357c46a1fa7efb15b8a0ab988e5dd0a24be646eb78f2"
  },
  "netPower": {
   "original_sha256": "3e22db0bc6aca59f93d188b3dab392fb5b33da7408ccc32ba5341d0ad4528095",
   "extracted_sha256": "3e22db0bc6aca59f93d188b3dab392fb5b33da7408ccc32ba5341d0ad4528095"
  },
  "totalTime": {
   "original_sha256": "ea4c6b4956d1767cf210da50bc45b391b0e0832264ed239f47d0d7f14eeb7b46",
   "extracted_sha256": "ea4c6b4956d1767cf210da50bc45b391b0e0832264ed239f47d0d7f14eeb7b46"
  }
 },
 "unranged": [],
 "added_assumptions": [],
 "conclusions_as_proved": {
  "salt_timing_answer": "\u2200 (U V cw p F G z : \u211d \u2192 \u211d) (K I H W k B0 B x : \u211d), \u21910 \u2264 I \u2192 \u2191923 \u2264 H \u2192 H \u2264 \u2191933 \u2192 V \u219125 - U \u219125 - K = saltMoles * (4.184 * (H + \u219187 + blend) + I) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, \u21914000 \u2264 cw t \u2227 \u21910 \u2264 p t) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, HasDerivAt U (waterCapacity cw p t) t) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) \u2192 \u219120 \u2264 B0 \u2192 B0 \u2264 B \u2192 B \u2264 \u2191100 \u2192 \u21910 < k \u2192 k * (B - \u219120) < W \u2192 (\u2200 (y : \u211d), V (z y) = U y + K) \u2192 (\u2200 y \u2208 Set.Icc (\u219120) B0, z y \u2208 Set.Icc (\u219119) B \u2227 DifferentiableAt \u211d z y) \u2192 (\u2200 t \u2208 Set.Icc (\u219119) B, HasDerivAt F (waterCapacity cw p t / netPower W k t) t \u2227 HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t) \u2192 x \u2208 Set.Icc (\u219120) B0 \u2192 z x < x \u2227 netPower W k (z x) - netPower W k x = k * (x - z x) \u2227 netPower W k x < netPower W k (z x) \u2227 totalTime F G z B \u219120 \u2264 totalTime F G z B x"
 },
 "extracted_file": "/work/checks/e19bacdc762e44f8bb76c4620e9c4221/extracted.lean",
 "errors": []
}
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "time": "2026-11-18T02:37:32.818969+00:00",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "extraction": {
    "file": "/work/checks/e19bacdc762e44f8bb76c4620e9c4221/submitted.lean",
    "conclusions": [
      "salt_timing_answer"
    ],
    "lean_exit": 0,
    "ok": true,
    "compiles_alone": true,
    "faithful": {
      "salt_timing_answer": true
    },
    "assumption_declarations": [
      "waterMass",
      "saltMoles",
      "blend",
      "calorimetricCurve",
      "apparentCapacity",
      "netPower",
      "totalTime",
      "waterCapacity",
      "real_scalar_continuity"
    ],
    "identity_method": "kernel-expression-repr-v1",
    "conclusion_identities": {
      "salt_timing_answer": {
        "original_sha256": "eea0f5a52b59f9246132f5903f12e0b471b3ab75ec9f5190d4bd51bf1e24a201",
        "extracted_sha256": "eea0f5a52b59f9246132f5903f12e0b471b3ab75ec9f5190d4bd51bf1e24a201"
      }
    },
    "dependency_faithful": {
      "saltMoles": true,
      "saltMoles._proof_1": true,
      "blend": true,
      "waterMass": true,
      "waterMass._proof_1": true,
      "real_scalar_continuity": true,
      "waterCapacity": true,
      "apparentCapacity": true,
      "calorimetricCurve": true,
      "calorimetricCurve._proof_1": true,
      "calorimetricCurve._proof_2": true,
      "calorimetricCurve._proof_3": true,
      "calorimetricCurve._proof_4": true,
      "apparentCapacity._proof_1": true,
      "netPower": true,
      "totalTime": true
    },
    "dependency_identities": {
      "saltMoles": {
        "original_sha256": "827bccd82e2687317f9129d38e31997f9f2a83127c0fcf5ab6bf61c947140dd5",
        "extracted_sha256": "827bccd82e2687317f9129d38e31997f9f2a83127c0fcf5ab6bf61c947140dd5"
      },
      "saltMoles._proof_1": {
        "original_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e",
        "extracted_sha256": "a052b10c67fb53d7d230a6030a8bdb3873a340a597be56e14e518c2949c4bd6e"
      },
      "blend": {
        "original_sha256": "0564ab882bd3f394420c6568a2a76aa7f9c3239ab5f7a2d7a22c57e50cf1192a",
        "extracted_sha256": "0564ab882bd3f394420c6568a2a76aa7f9c3239ab5f7a2d7a22c57e50cf1192a"
      },
      "waterMass": {
        "original_sha256": "54cdbd23ea81ba012ab9e6257436e9f54431a1eec79c5351523168154c27f078",
        "extracted_sha256": "54cdbd23ea81ba012ab9e6257436e9f54431a1eec79c5351523168154c27f078"
      },
      "waterMass._proof_1": {
        "original_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8",
        "extracted_sha256": "f952723ace8680854ad361cd5f02b3b25c9607d68dbd69a3860528a1ccd513a8"
      },
      "real_scalar_continuity": {
        "original_sha256": "11472ac66ebf7ba9b8ae413c640c759d5b83f1c272f054e99ec50cb0a9eeadbf",
        "extracted_sha256": "11472ac66ebf7ba9b8ae413c640c759d5b83f1c272f054e99ec50cb0a9eeadbf"
      },
      "waterCapacity": {
        "original_sha256": "5ad429c7ec6f40440a6d5a145584438fb93a8b06f115cc9010f714bb382dd411",
        "extracted_sha256": "5ad429c7ec6f40440a6d5a145584438fb93a8b06f115cc9010f714bb382dd411"
      },
      "apparentCapacity": {
        "original_sha256": "ee228915221a930df961bddf28427bb24076b73fbab345b3a0d9cde5f78df92b",
        "extracted_sha256": "ee228915221a930df961bddf28427bb24076b73fbab345b3a0d9cde5f78df92b"
      },
      "calorimetricCurve": {
        "original_sha256": "4a4538aa3d3e0d4285eecafdac9d81b13ad47e8d382f5eb7964cac93e33ab328",
        "extracted_sha256": "4a4538aa3d3e0d4285eecafdac9d81b13ad47e8d382f5eb7964cac93e33ab328"
      },
      "calorimetricCurve._proof_1": {
        "original_sha256": "e72460529fc291789692b7a1d53e45b82e9c6684e8a3b5aa7472abea5e34b3a4",
        "extracted_sha256": "e72460529fc291789692b7a1d53e45b82e9c6684e8a3b5aa7472abea5e34b3a4"
      },
      "calorimetricCurve._proof_2": {
        "original_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363",
        "extracted_sha256": "922f2846ad8bc91466725ac64874f5b98438bfaf36727fca53e5fe17cba09363"
      },
      "calorimetricCurve._proof_3": {
        "original_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae",
        "extracted_sha256": "7653daabee7aa26ed365d38a4e6cfafbc4ca93b290219d55e91bfd114e0827ae"
      },
      "calorimetricCurve._proof_4": {
        "original_sha256": "27a39ed7b1e9bbfe47c55794101d03a078de3a98d6b443fa3f39bbcb7f2437f9",
        "extracted_sha256": "27a39ed7b1e9bbfe47c55794101d03a078de3a98d6b443fa3f39bbcb7f2437f9"
      },
      "apparentCapacity._proof_1": {
        "original_sha256": "e7b45ed9c39659bc3b75357c46a1fa7efb15b8a0ab988e5dd0a24be646eb78f2",
        "extracted_sha256": "e7b45ed9c39659bc3b75357c46a1fa7efb15b8a0ab988e5dd0a24be646eb78f2"
      },
      "netPower": {
        "original_sha256": "3e22db0bc6aca59f93d188b3dab392fb5b33da7408ccc32ba5341d0ad4528095",
        "extracted_sha256": "3e22db0bc6aca59f93d188b3dab392fb5b33da7408ccc32ba5341d0ad4528095"
      },
      "totalTime": {
        "original_sha256": "ea4c6b4956d1767cf210da50bc45b391b0e0832264ed239f47d0d7f14eeb7b46",
        "extracted_sha256": "ea4c6b4956d1767cf210da50bc45b391b0e0832264ed239f47d0d7f14eeb7b46"
      }
    },
    "unranged": [],
    "added_assumptions": [],
    "conclusions_as_proved": {
      "salt_timing_answer": "\u2200 (U V cw p F G z : \u211d \u2192 \u211d) (K I H W k B0 B x : \u211d), \u21910 \u2264 I \u2192 \u2191923 \u2264 H \u2192 H \u2264 \u2191933 \u2192 V \u219125 - U \u219125 - K = saltMoles * (4.184 * (H + \u219187 + blend) + I) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, \u21914000 \u2264 cw t \u2227 \u21910 \u2264 p t) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, HasDerivAt U (waterCapacity cw p t) t) \u2192 (\u2200 t \u2208 Set.Icc \u219119 \u2191100, HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) \u2192 \u219120 \u2264 B0 \u2192 B0 \u2264 B \u2192 B \u2264 \u2191100 \u2192 \u21910 < k \u2192 k * (B - \u219120) < W \u2192 (\u2200 (y : \u211d), V (z y) = U y + K) \u2192 (\u2200 y \u2208 Set.Icc (\u219120) B0, z y \u2208 Set.Icc (\u219119) B \u2227 DifferentiableAt \u211d z y) \u2192 (\u2200 t \u2208 Set.Icc (\u219119) B, HasDerivAt F (waterCapacity cw p t / netPower W k t) t \u2227 HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t) \u2192 x \u2208 Set.Icc (\u219120) B0 \u2192 z x < x \u2227 netPower W k (z x) - netPower W k x = k * (x - z x) \u2227 netPower W k x < netPower W k (z x) \u2227 totalTime F G z B \u219120 \u2264 totalTime F G z B x"
    },
    "extracted_file": "/work/checks/e19bacdc762e44f8bb76c4620e9c4221/extracted.lean",
    "errors": []
  },
  "scientific_relevance": "requires human review"
}
shell input
{
  "command": "/usr/bin/bash -lc \"python - <<'PY'\nimport json\np='/work/checks/e19bacdc762e44f8bb76c4620e9c4221/verdict.json'\nr=json.load(open(p))\nprint(json.dumps({k:r.get(k) for k in ['ok','check_complete','reviewable','verdict','lean_exit','added_assumptions','conditional_on','scientific_relevance']},indent=2))\nPY\""
}
shell output · exit 0
{
  "ok": true,
  "check_complete": true,
  "reviewable": true,
  "verdict": "proved",
  "lean_exit": 0,
  "added_assumptions": [],
  "conditional_on": [],
  "scientific_relevance": "requires human review"
}
assistant
The supplied facts do not determine a universal addition temperature or waiting time.

Under the revised, explicitly conditional 10 g NaCl model, **add immediately at 20 °C**. The proof includes variable heat capacity, mixing energy and the resulting change in net heating power.

[Candidate](/work/candidate.json) passed faithful extraction and kernel checking. [Report](/work/report.txt) exposes the unvalidated temperature extrapolation and phase assumptions. Human review remains pending.

Produced code

attempt-005/Model.lean
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import Mathlib.Tactic.NormNum

/- Volume in litres, density in g/cm³, result in kg. -/
noncomputable def waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000
noncomputable def saltMoles : ℝ := 10 / 58.443
/- Affine composition coordinate between Parker's measured molalities.
   Affinity in composition is a modeling choice, not a consequence of two rows. -/
noncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)

/- Rational family (a*t+b)/(t+r), identified from three calorimetric
   values. First differences determine r; two equations then give a,b.
   This is an empirical family choice, not a claimed law of electrolytes. -/
noncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=
  let d1 := y25-y20
  let d2 := y30-y25
  let r := (30*d2-20*d1)/(d1-d2)
  let a := (y25*(25+r)-y20*(20+r))/5
  let b := y20*(20+r)-20*a
  (a*t+b)/(t+r)

/- Apparent molar capacity J/(mol K), fitted to Parker table II C.
   Affine composition interpolation and extension to 19..100 C are
   independent empirical choices, not certified consequences of the data. -/
noncomputable def apparentCapacity (t : ℝ) : ℝ :=
  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +
    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)

lemma capacity_formula : ∀ t : ℝ,
    apparentCapacity t =
      4.184*((1-blend)*((-13*t-2314)/(3*t+70)) +
        blend*((2*t-1275)/(t+45))) := by
  intro t
  unfold apparentCapacity calorimetricCurve
  norm_num
  have hratio : (-(13/3*t) + -(2314/3))/(t+70/3) =
      (-(13*t)-2314)/(3*t+70) := by
    field_simp
    <;> ring
  rw [hratio]
  ring

def netPower (W k t : ℝ) : ℝ := W - k * (t - 20)
/- F,G are inverse first-law time primitives for water and brine. -/
noncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=
  F x - F 20 + G B - G (z x)

/- Identification, not hand-picked rational parameters: multiplying
   y=(a*t+b)/(t+r) by its denominator gives a linear identification system.
   These implications uniquely solve that system for both compositions. -/
lemma calorimetric_identification :
    ∀ a b r : ℝ,
    (-19.8)*(20+r)=a*20+b → (-18.2)*(25+r)=a*25+b →
    (-16.9)*(30+r)=a*30+b → a = -13/3 ∧ b = -2314/3 ∧ r = 70/3 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma calorimetric_identification_upper :
    ∀ a b r : ℝ,
    (-19)*(20+r)=a*20+b → (-17.5)*(25+r)=a*25+b →
    (-16.2)*(30+r)=a*30+b → a = 2 ∧ b = -1275 ∧ r = 45 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma composition_inference :
    waterMass = 0.99820675 ∧ 0 < saltMoles ∧ saltMoles < 0.18 ∧
    0 ≤ blend ∧ blend ≤ 1 := by
  norm_num [waterMass, saltMoles, blend]

/- Rigorous bounds on the DECLARED rational family, not measured error bars.
   Two chords bound the concave capacity curves from below. -/
lemma capacity_bounds :
    ∀ t : ℝ, t ∈ Set.Icc 19 100 →
    -100 ≤ apparentCapacity t ∧ apparentCapacity t ≤ 0 ∧
    (25 ≤ t → t ≤ 60 → -77 + (25/35)*(t-25) ≤ apparentCapacity t) ∧
    (60 ≤ t → -52 + (11/40)*(t-60) ≤ apparentCapacity t) := by
  intro t ht
  obtain ⟨hm, hn, hnhi, hw, hw1⟩ := composition_inference
  have hd : 0 < 3*t+70 := by linarith [ht.1]
  have he : 0 < t+45 := by linarith [ht.1]
  have hlo : -100/4.184 ≤ (-13*t-2314)/(3*t+70) := by
    apply (le_div_iff₀ hd).2
    nlinarith [ht.1]
  have hup : -100/4.184 ≤ (2*t-1275)/(t+45) := by
    apply (le_div_iff₀ he).2
    nlinarith [ht.1]
  have hln : (-13*t-2314)/(3*t+70) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.1]) (le_of_lt hd)
  have hun : (2*t-1275)/(t+45) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.2]) (le_of_lt he)
  have combine : ∀ l, l ≤ 4.184*((-13*t-2314)/(3*t+70)) →
      l ≤ 4.184*((2*t-1275)/(t+45)) → l ≤ apparentCapacity t := by
    intro l hl hu
    rw [capacity_formula]
    nlinarith [mul_nonneg (sub_nonneg.mpr hw1) (sub_nonneg.mpr hl),
      mul_nonneg hw (sub_nonneg.mpr hu)]
  refine ⟨combine (-100) (by nlinarith) (by nlinarith), ?_, ?_, ?_⟩
  · rw [capacity_formula]
    nlinarith [mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hw1) hln,
      mul_nonpos_of_nonneg_of_nonpos hw hun]
  · intro h25 h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
  · intro h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith

/- Differential comparison integrates an inequality without assuming
   numerical quadrature or replacing a secant by a local heat capacity. -/
lemma differential_comparison :
    ∀ (f g : ℝ → ℝ) (df dg : ℝ → ℝ) (a b : ℝ), a ≤ b →
    (∀ t ∈ Set.Icc a b, HasDerivAt f (df t) t) →
    (∀ t ∈ Set.Icc a b, HasDerivAt g (dg t) t) →
    (∀ t ∈ Set.Icc a b, dg t ≤ df t) →
    g b - g a ≤ f b - f a := by
  intro f g df dg a b hab hf hg hle
  have hm : MonotoneOn (fun t => f t - g t) (Set.Icc a b) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro t ht; exact ((hf t ht).sub (hg t ht)).continuousAt.continuousWithinAt
    · intro t ht; exact ((hf t (interior_subset ht)).sub (hg t (interior_subset ht))).hasDerivWithinAt
    · intro t ht; exact sub_nonneg.mpr (hle t (interior_subset ht))
  have h := hm ⟨le_rfl,hab⟩ ⟨hab,le_rfl⟩ hab
  linarith

/- d is enthalpy of brine minus original water and stored 20 C solid,
   per mole. I is solid sensible enthalpy 20->25 C. Positivity alone
   suffices: no extrapolated solid Cp or numerical solid integral is used.
   Parker anchor 928 cal/mol + affine finite-composition 87..88 cal/mol.
   d'=absolute apparent capacity is Kirchhoff's law with fixed solid. -/
lemma material_enthalpy_positive :
    ∀ (d : ℝ → ℝ) (I H : ℝ), 0 ≤ I → 923 ≤ H →
    d 25 = 4.184*(H+87+blend)+I →
    (∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t) →
    ∀ t ∈ Set.Icc 20 100, 100 < d t := by
  intro d I H hI hH ha hd t ht
  have hanchor : 4225 ≤ d 25 := by
    have hw := composition_inference.2.2.2.1
    linarith
  have hdec : ∀ a b : ℝ, 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a := by
    intro a b hal hbh hab
    have h := differential_comparison (fun x => -d x) (fun _ => 0)
      (fun x => -apparentCapacity x) (fun _ => 0) a b hab
      (by intro x hx; exact (hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩).neg)
      (by intro x hx; exact hasDerivAt_const x 0)
      (by intro x hx; exact neg_nonneg.mpr (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.1)
    linarith
  have hfirst : d 25 - 2257.5 ≤ d 60 := by
    have h := differential_comparison d
      (fun x => -77*(x-25)+(25/70)*(x-25)^2)
      apparentCapacity (fun x => -77+(25/35)*(x-25)) 25 60 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 25).const_mul (-77) |>.add
            ((((hasDerivAt_id x).sub_const 25).pow 2).const_mul (25/70)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.1 hx.1 hx.2)
    norm_num at h; linarith
  have hsecond : d 60 - 1860 ≤ d 100 := by
    have h := differential_comparison d
      (fun x => -52*(x-60)+(11/80)*(x-60)^2)
      apparentCapacity (fun x => -52+(11/40)*(x-60)) 60 100 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 60).const_mul (-52) |>.add
            ((((hasDerivAt_id x).sub_const 60).pow 2).const_mul (11/80)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.2 hx.1)
    norm_num at h; linarith
  have hend := hdec t 100 (by linarith [ht.1]) le_rfl ht.2
  linarith

/- The shared loss law derives a power change from the mixing jump;
   no independent before/after heating powers are introduced. -/
lemma newtonian_power_change : ∀ W k x z : ℝ,
    netPower W k z - netPower W k x = k*(x-z) := by
  intro W k x z
  unfold netPower
  ring

/- Variable component storage, J/K: liquid-water specific Cp cw in
   J/(kg K), plus nonnegative pot capacity p in J/K. -/
noncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=
  waterMass * cw t + p t

/- Technical library fact, proved rather than assumed. Naming this proof
   prevents the extractor from replacing an implicit continuity proof by
   a fresh auxiliary constant. It adds no physical premise. -/
lemma real_scalar_continuity : ContinuousSMul ℝ ℝ := by infer_instance

/- Scientific conclusion. All thermodynamic and first-law premises are
   visible. z is the differentiable, liquid-valued mixing solution;
   its existence/phase admissibility is an exposed physical guard.
   No boiling dwell is allowed: addition x ends at pure-water onset B0.
   The recommendation is conditional on the empirical rational family,
   its composition interpolation and its full-temperature applicability. -/
theorem salt_timing_answer :
    ∀ (U V cw p F G z : ℝ → ℝ) (K I H W k B0 B x : ℝ),
    ((0 : ℕ) : ℝ) ≤ I → ((923 : ℕ) : ℝ) ≤ H → H ≤ ((933 : ℕ) : ℝ) →
    V ((25 : ℕ) : ℝ) - U ((25 : ℕ) : ℝ) - K = saltMoles * (4.184*(H+((87 : ℕ) : ℝ)+blend)+I) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), ((4000 : ℕ) : ℝ) ≤ cw t ∧ ((0 : ℕ) : ℝ) ≤ p t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity U (waterCapacity cw p t) t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ),
      @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) →
    ((20 : ℕ) : ℝ) ≤ B0 → B0 ≤ B → B ≤ ((100 : ℕ) : ℝ) → ((0 : ℕ) : ℝ) < k → k*(B-((20 : ℕ) : ℝ)) < W →
    (∀ y, V (z y) = U y + K) →
    (∀ y ∈ Set.Icc ((20 : ℕ) : ℝ) B0, z y ∈ Set.Icc ((19 : ℕ) : ℝ) B ∧ DifferentiableAt ℝ z y) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) B,
      @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity F (waterCapacity cw p t / netPower W k t) t ∧
      @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity G ((waterCapacity cw p t + saltMoles * apparentCapacity t) /
        netPower W k t) t) →
    x ∈ Set.Icc ((20 : ℕ) : ℝ) B0 →
    z x < x ∧
    netPower W k (z x) - netPower W k x = k*(x-z x) ∧
    netPower W k x < netPower W k (z x) ∧
    totalTime F G z B ((20 : ℕ) : ℝ) ≤ totalTime F G z B x := by
  intro U V cw p F G z K I H W k B0 B x hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx
  norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV hB0 hB0B hB hk hW hmix hz hFG hx ⊢
  obtain ⟨hmass, hn, hnhi, hw, hw1⟩ := composition_inference
  have hN : saltMoles ≠ 0 := ne_of_gt hn
  have hstorage : ∀ t ∈ Set.Icc 19 100,
      0 < waterCapacity cw p t ∧
      0 < waterCapacity cw p t + saltMoles * apparentCapacity t := by
    intro t ht
    obtain ⟨hcw, hp⟩ := hcomponents t ht
    have hcp := (capacity_bounds t ht).1
    have hbound := mul_nonneg (le_of_lt hn) (show 0 ≤ apparentCapacity t + 100 by linarith)
    unfold waterCapacity
    rw [hmass]
    constructor <;> nlinarith
  have hd : ∀ t ∈ Set.Icc 20 100,
      100 < (V t - U t - K) / saltMoles := by
    apply material_enthalpy_positive (fun t => (V t-U t-K)/saltMoles) I H hI hH
    · rw [ha]; field_simp <;> norm_num <;> ring
    · intro t ht
      convert (((hV t ht).sub (hU t ht)).sub_const K).div_const saltMoles using 1
      field_simp
      ring
  have hVm : StrictMonoOn V (Set.Icc 19 100) := by
    apply strictMonoOn_of_hasDerivWithinAt_pos (convex_Icc _ _)
    · intro t ht; exact (hV t ht).continuousAt.continuousWithinAt
    · intro t ht; exact (hV t (interior_subset ht)).hasDerivWithinAt
    · intro t ht; exact (hstorage t (interior_subset ht)).2
  have hcool : ∀ y ∈ Set.Icc 20 B0, z y < y := by
    intro y hy
    have hy100 : y ∈ Set.Icc 19 100 := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨(hz y hy).1.1,by linarith [(hz y hy).1.2]⟩
    have hdpos := (lt_div_iff₀ hn).1 (hd y ⟨hy.1,by linarith [hy.2]⟩)
    by_contra h
    have hle : V y ≤ V (z y) := hVm.monotoneOn hy100 hz100 (le_of_not_gt h)
    rw [hmix y] at hle
    nlinarith
  have hpower : ∀ t ∈ Set.Icc 19 B, 0 < netPower W k t := by
    intro t ht
    unfold netPower
    nlinarith [ht.2]
  have hder : ∀ y ∈ Set.Icc 20 B0,
      HasDerivAt (totalTime F G z B)
        (waterCapacity cw p y *
          (1 / netPower W k y - 1 / netPower W k (z y))) y := by
    intro y hy
    have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hy100 : y ∈ Set.Icc 19 100 := ⟨hyB.1,by linarith [hyB.2]⟩
    have hzB := (hz y hy).1
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨hzB.1,by linarith [hzB.2]⟩
    have hchain := (hV (z y) hz100).comp y (hz y hy).2.hasDerivAt
    have hid : (fun t => V (z t)) = (fun t => U t + K) := funext hmix
    change HasDerivAt (fun t => V (z t)) _ y at hchain
    rw [hid] at hchain
    have he := hchain.unique ((hU y hy100).add_const K)
    have ht := (((hFG y hyB).1.sub_const (F 20)).add_const (G B)).sub
      ((hFG (z y) hzB).2.comp y (hz y hy).2.hasDerivAt)
    change HasDerivAt (totalTime F G z B) _ y at ht
    convert ht using 1
    have hny := ne_of_gt (hpower y hyB)
    have hnz := ne_of_gt (hpower (z y) hzB)
    field_simp [hny, hnz]
    have he' := congrArg (fun a : ℝ => netPower W k y * a) he
    nlinarith only [he']
  have hmon : MonotoneOn (totalTime F G z B) (Set.Icc 20 B0) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy; exact (hder y hy).continuousAt.continuousWithinAt
    · intro y hy; exact (hder y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hyI := interior_subset hy
      have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hyI.1],by linarith [hyI.2]⟩
      have hny := hpower y hyB
      have hnz := hpower (z y) (hz y hyI).1
      have horder : netPower W k y ≤ netPower W k (z y) := by
        unfold netPower; nlinarith [hcool y hyI]
      have hrecip : 1 / netPower W k (z y) ≤ 1 / netPower W k y :=
        one_div_le_one_div_of_le hny horder
      exact mul_nonneg (le_of_lt (hstorage y ⟨hyB.1,by linarith [hyB.2]⟩).1)
        (sub_nonneg.mpr hrecip)
  refine ⟨hcool x hx, newtonian_power_change W k x (z x), ?_,
    hmon ⟨le_rfl,hB0⟩ hx hx.1⟩
  unfold netPower
  nlinarith [hcool x hx]
attempt-005/extracted.lean
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import Mathlib.Tactic.NormNum

noncomputable def waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000

noncomputable def saltMoles : ℝ := 10 / 58.443

noncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)

noncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=
  let d1 := y25-y20
  let d2 := y30-y25
  let r := (30*d2-20*d1)/(d1-d2)
  let a := (y25*(25+r)-y20*(20+r))/5
  let b := y20*(20+r)-20*a
  (a*t+b)/(t+r)

noncomputable def apparentCapacity (t : ℝ) : ℝ :=
  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +
    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)

def netPower (W k t : ℝ) : ℝ := W - k * (t - 20)

noncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=
  F x - F 20 + G B - G (z x)

noncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=
  waterMass * cw t + p t

lemma real_scalar_continuity : ContinuousSMul ℝ ℝ := by infer_instance


/-! Conclusions (statements of the proved theorems). -/
def conclusion_salt_timing_answer : Prop := ∀ (U V cw p F G z : ℝ → ℝ) (K I H W k B0 B x : ℝ), ((0 : ℕ) : ℝ) ≤ I → ((923 : ℕ) : ℝ) ≤ H → H ≤ ((933 : ℕ) : ℝ) → V ((25 : ℕ) : ℝ) - U ((25 : ℕ) : ℝ) - K = saltMoles * (4.184*(H+((87 : ℕ) : ℝ)+blend)+I) → (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), ((4000 : ℕ) : ℝ) ≤ cw t ∧ ((0 : ℕ) : ℝ) ≤ p t) → (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity U (waterCapacity cw p t) t) → (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) → ((20 : ℕ) : ℝ) ≤ B0 → B0 ≤ B → B ≤ ((100 : ℕ) : ℝ) → ((0 : ℕ) : ℝ) < k → k*(B-((20 : ℕ) : ℝ)) < W → (∀ y, V (z y) = U y + K) → (∀ y ∈ Set.Icc ((20 : ℕ) : ℝ) B0, z y ∈ Set.Icc ((19 : ℕ) : ℝ) B ∧ DifferentiableAt ℝ z y) → (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) B, @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity F (waterCapacity cw p t / netPower W k t) t ∧ @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity G ((waterCapacity cw p t + saltMoles * apparentCapacity t) / netPower W k t) t) → x ∈ Set.Icc ((20 : ℕ) : ℝ) B0 → z x < x ∧ netPower W k (z x) - netPower W k x = k*(x-z x) ∧ netPower W k x < netPower W k (z x) ∧ totalTime F G z B ((20 : ℕ) : ℝ) ≤ totalTime F G z B x
checks/0a52ddc3554b4e10b6c5b477fceb0093/submitted.lean
import Mathlib.Analysis.SpecialFunctions.Log.Deriv
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring

/- Supplied starting temperature in degrees Celsius. -/
def initialTemperature : ℝ := 20

/- Constant heater input W, room temperature A, linear heat-loss
   coefficient k. This SAME law applies to water and brine (watts). -/
def netPower (W k A T : ℝ) : ℝ := W - k * (T - A)

/- Instantaneous conservation of energy on adding salt: C is water+pot
   capacity, S = final solution capacity minus original water capacity (signed),
   Ts salt temperature and enthalpy reference, H dissolution energy at Ts. Capacities J/K, H joules. -/
noncomputable def mixedTemperature (C S H Ts x : ℝ) : ℝ :=
  (C * x + S * Ts - H) / (C + S)

/- Integrated inverse energy balance dt/dT = capacity/netPower(T).
   Used only where net power is positive and k>0. -/
noncomputable def heatingTime (capacity W k A u v : ℝ) : ℝ :=
  capacity / k * (Real.log (netPower W k A u) - Real.log (netPower W k A v))

/- Total seconds to a fixed final solution boiling temperature B when
   salt is added at unsalted temperature x. The mixing temperature jump and the
   changed heat capacity are both included. -/
noncomputable def boilingTime (C S H Ts B W k A x : ℝ) : ℝ :=
  heatingTime C W k A initialTemperature x +
  heatingTime (C + S) W k A (mixedTemperature C S H Ts x) B

/- H is the isothermal dissolution energy at Ts, not at every x.
   If cs is solid salt capacity, Kirchhoff gives dissolution energy
   H+(S-cs)*(x-Ts) at x. Warming the solid to x costs cs*(x-Ts).
   Thus their sum is H+S*(x-Ts), for either sign of S. -/
lemma reference_consistent_balance :
    ∀ (C S H Ts cs x z : ℝ), C + S ≠ 0 →
    ((C + S) * (z - x) + cs * (x - Ts) +
      (H + (S - cs) * (x - Ts)) = 0 ↔
      z = mixedTemperature C S H Ts x) := by
  intro C S H Ts cs x z hc
  unfold mixedTemperature
  rw [eq_div_iff hc]
  constructor <;> intro h <;> nlinarith

/- Derived conservation of enthalpy; no presumed mixing-temperature sign. -/
lemma mixing_balance :
    ∀ (C S H Ts x : ℝ), C + S ≠ 0 →
    (C + S) * mixedTemperature C S H Ts x = C * x + S * Ts - H := by
  intro C S H Ts x hc
  unfold mixedTemperature
  field_simp

/- Derive the net-power jump from energy conservation AND the shared
   heat-transfer law; before/after powers are not independent parameters. -/
lemma power_change :
    ∀ (C S H Ts W k A x : ℝ), C + S ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S) := by
  intro C S H Ts W k A x hc
  unfold netPower mixedTemperature
  field_simp
  ring

lemma power_derivative :
    ∀ (W k A x : ℝ), HasDerivAt (netPower W k A) (-k) x := by
  intro W k A x
  unfold netPower
  convert (((hasDerivAt_id x).sub_const A).const_mul k).const_sub W using 1 <;> simp

/- Checks the integrated heating law against the differential first law:
   increasing endpoint temperature costs capacity/netPower seconds/K. -/
lemma heating_time_derivative :
    ∀ (capacity W k A u v : ℝ), k ≠ 0 → netPower W k A v ≠ 0 →
    HasDerivAt (fun y => heatingTime capacity W k A u y)
      (capacity / netPower W k A v) v := by
  intro capacity W k A u v hk hv
  have h := (((power_derivative W k A v).log hv).const_sub
    (Real.log (netPower W k A u))).const_mul (capacity / k)
  unfold heatingTime
  convert h using 1
  field_simp [hk, hv]

/- Derivation of the stage-time formula from the inverse first law.
   For any elapsed-time curve f with df/dT = capacity/netPower and f(u)=0,
   the endpoint time MUST equal heatingTime; it is not a fitted formula.
   Endpoint derivatives may be read as those of a smooth local extension. -/
lemma stage_time_from_energy :
    ∀ (capacity W k A u v : ℝ) (f : ℝ → ℝ),
    u ≤ v → k ≠ 0 →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y) →
    (∀ y ∈ Set.Icc u v, HasDerivAt f (capacity / netPower W k A y) y) →
    f u = 0 → f v = heatingTime capacity W k A u v := by
  intro capacity W k A u v f huv hk hp hf hu
  have mono : ∀ (g : ℝ → ℝ),
      (∀ y ∈ Set.Icc u v, HasDerivAt g 0 y) → MonotoneOn g (Set.Icc u v) := by
    intro g hg
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hg y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hg y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      exact le_refl 0
  have hd : ∀ y ∈ Set.Icc u v,
      HasDerivAt (fun w => f w - heatingTime capacity W k A u w) 0 y := by
    intro y hy
    have hh := heating_time_derivative capacity W k A u y hk (ne_of_gt (hp y hy))
    convert (hf y hy).sub hh using 1 <;> simp
  have hm := mono (fun w => f w - heatingTime capacity W k A u w) hd
  have hn := mono (fun w => -(f w - heatingTime capacity W k A u w)) (by
    intro y hy
    convert (hd y hy).neg using 1 <;> simp)
  have hle := hm ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hge := hn ⟨le_refl u, huv⟩ ⟨huv, le_refl v⟩ huv
  have hzero : heatingTime capacity W k A u u = 0 := by
    simp only [heatingTime, sub_self, mul_zero]
  linarith

/- Eliminate the two heating stages. The derivative compares the time
   spent heating unsalted water with the time saved in the salted stage. -/
lemma boiling_time_derivative :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C / netPower W k A x -
       C / netPower W k A (mixedTemperature C S H Ts x)) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hm : HasDerivAt (mixedTemperature C S H Ts) (C / (C + S)) x := by
    unfold mixedTemperature
    convert ((((hasDerivAt_id x).const_mul C).add_const (S * Ts)).sub_const H).div_const
      (C + S) using 1 <;> simp
  have hn := (power_derivative W k A (mixedTemperature C S H Ts x)).comp x hm
  have hpost := (((hn.log hz).sub_const
    (Real.log (netPower W k A B))).const_mul ((C + S) / k))
  have hpre := heating_time_derivative C W k A initialTemperature x hk hx
  convert hpre.add hpost using 1
  · rfl
  · dsimp only [Function.comp_apply]
    field_simp [hc, hk, hx, hz]
    ring

/- The derivative has precisely the sign of the net cooling energy
   D(x)=S*(x-Ts)+H when capacities and net powers are positive. -/
lemma timing_derivative_signed :
    ∀ (C S H Ts B W k A x : ℝ), C + S ≠ 0 → k ≠ 0 →
    netPower W k A x ≠ 0 →
    netPower W k A (mixedTemperature C S H Ts x) ≠ 0 →
    HasDerivAt (boilingTime C S H Ts B W k A)
      (C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x))) x := by
  intro C S H Ts B W k A x hc hk hx hz
  have hj := power_change C S H Ts W k A x hc
  have he : C / netPower W k A x - C / netPower W k A (mixedTemperature C S H Ts x) =
      C * (k * (S * (x - Ts) + H) / (C + S)) /
        (netPower W k A x * netPower W k A (mixedTemperature C S H Ts x)) := by
    rw [← hj]
    field_simp
    <;> ring
  rw [← he]
  exact boiling_time_derivative C S H Ts B W k A x hc hk hx hz

/- Constant-capacity mixing is increasing in the addition temperature,
   even if S<0. Endpoint constraints keep the entire trajectory liquid.
   F is a common liquid lower bound; B0 is unsalted boiling temperature. -/
lemma feasible_trajectory :
    ∀ (C S H Ts B W k A F B0 L U y : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    y ∈ Set.Icc L U →
    (initialTemperature ≤ y ∧ y ≤ B0) ∧
    (F ≤ mixedTemperature C S H Ts y ∧ mixedTemperature C S H Ts y ≤ B) ∧
    (0 < netPower W k A y ∧ 0 < netPower W k A (mixedTemperature C S H Ts y)) := by
  intro C S H Ts B W k A F B0 L U y hC hc hk hF hi hLU hU hzl hzu hpU hpB hy
  have hzmono : Monotone (mixedTemperature C S H Ts) := by
    intro a b hab
    unfold mixedTemperature
    exact (div_le_div_iff_of_pos_right hc).2 (by nlinarith)
  have hzlo := le_trans hzl (hzmono hy.1)
  have hzhi := le_trans (hzmono hy.2) hzu
  refine ⟨⟨le_trans hi hy.1, le_trans hy.2 hU⟩, ⟨hzlo, hzhi⟩, ?_⟩
  unfold netPower at *
  constructor <;> nlinarith [hy.2]

/- Comparing stages on any feasible subinterval, using the derived sign. -/
lemma time_increasing_on_cooling :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
    boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (boilingTime C S H Ts B W k A) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      exact div_nonneg (mul_nonneg (le_of_lt hC)
        (div_nonneg (mul_nonneg (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
        (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
  exact hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv

lemma time_decreasing_on_warming :
    ∀ (C S H Ts B W k A u v : ℝ),
    0 < C → 0 < C + S → 0 < k → u ≤ v →
    (∀ y ∈ Set.Icc u v, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y)) →
    (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
    boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
  intro C S H Ts B W k A u v hC hc hk huv hp hs
  have hd := fun y hy => timing_derivative_signed C S H Ts B W k A y
    (ne_of_gt hc) (ne_of_gt hk) (ne_of_gt (hp y hy).1) (ne_of_gt (hp y hy).2)
  have hm : MonotoneOn (fun y => -boilingTime C S H Ts B W k A y) (Set.Icc u v) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy
      exact (hd y hy).neg.continuousAt.continuousWithinAt
    · intro y hy
      exact (hd y (interior_subset hy)).neg.hasDerivWithinAt
    · intro y hy
      have hm := interior_subset hy
      have hn : C * (k * (S * (y - Ts) + H) / (C + S)) /
          (netPower W k A y * netPower W k A (mixedTemperature C S H Ts y)) ≤ 0 :=
        div_nonpos_of_nonpos_of_nonneg
          (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hC)
            (div_nonpos_of_nonpos_of_nonneg
              (mul_nonpos_of_nonneg_of_nonpos (le_of_lt hk) (hs y hm)) (le_of_lt hc)))
          (le_of_lt (mul_pos (hp y hm).1 (hp y hm).2))
      exact neg_nonneg.mpr hn
  have hh := hm ⟨le_refl _, huv⟩ ⟨huv, le_refl _⟩ huv
  linarith

/- Conditional scientific answer over an explicitly feasible interval.
   S>=0: earliest, latest, or interior root as D changes sign.
   S<=0: compare endpoint boiling times. S=H=0: all schedules tie.
   H is allowed either sign; mixing need not cool or increase net power. -/
theorem addition_timing_answer :
    ∀ (C S H Ts B W k A F B0 L U x : ℝ),
    0 < C → 0 < C + S → 0 < k →
    F ≤ initialTemperature → initialTemperature ≤ L → L ≤ U → U ≤ B0 →
    F ≤ mixedTemperature C S H Ts L → mixedTemperature C S H Ts U ≤ B →
    0 < netPower W k A U → 0 < netPower W k A B →
    x ∈ Set.Icc L U →
    (netPower W k A (mixedTemperature C S H Ts x) - netPower W k A x =
      k * (S * (x - Ts) + H) / (C + S)) ∧
    (0 ≤ S → 0 ≤ S * (L - Ts) + H →
      boilingTime C S H Ts B W k A L ≤ boilingTime C S H Ts B W k A x) ∧
    (0 ≤ S → S * (U - Ts) + H ≤ 0 →
      boilingTime C S H Ts B W k A U ≤ boilingTime C S H Ts B W k A x) ∧
    (0 < S → Ts - H / S ∈ Set.Icc L U →
      boilingTime C S H Ts B W k A (Ts - H / S) ≤ boilingTime C S H Ts B W k A x) ∧
    (S ≤ 0 →
      min (boilingTime C S H Ts B W k A L) (boilingTime C S H Ts B W k A U) ≤
        boilingTime C S H Ts B W k A x) ∧
    (S = 0 → H = 0 →
      boilingTime C S H Ts B W k A L = boilingTime C S H Ts B W k A x) := by
  intro C S H Ts B W k A F B0 L U x hC hc hk hF hi hLU hU hzl hzu hpU hpB hx
  have hp : ∀ y ∈ Set.Icc L U, 0 < netPower W k A y ∧
      0 < netPower W k A (mixedTemperature C S H Ts y) := by
    intro y hy
    exact (feasible_trajectory C S H Ts B W k A F B0 L U y
      hC hc hk hF hi hLU hU hzl hzu hpU hpB hy).2.2
  have inc : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, 0 ≤ S * (y - Ts) + H) →
      boilingTime C S H Ts B W k A u ≤ boilingTime C S H Ts B W k A v := by
    intro u v hlu hvu huv hs
    apply time_increasing_on_cooling C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  have dec : ∀ u v, L ≤ u → v ≤ U → u ≤ v →
      (∀ y ∈ Set.Icc u v, S * (y - Ts) + H ≤ 0) →
      boilingTime C S H Ts B W k A v ≤ boilingTime C S H Ts B W k A u := by
    intro u v hlu hvu huv hs
    apply time_decreasing_on_warming C S H Ts B W k A u v hC hc hk huv
    · intro y hy
      exact hp y ⟨le_trans hlu hy.1, le_trans hy.2 hvu⟩
    · exact hs
  refine ⟨power_change C S H Ts W k A x (ne_of_gt hc), ?_, ?_, ?_, ?_, ?_⟩
  · intro hS hD
    apply inc L x (le_refl _) hx.2 hx.1
    intro y hy
    nlinarith [hy.1]
  · intro hS hD
    apply dec x U hx.1 (le_refl _) hx.2
    intro y hy
    nlinarith [hy.2]
  · intro hS hr
    have hroot : S * ((Ts - H / S) - Ts) + H = 0 := by
      field_simp
      <;> ring
    by_cases hxr : x ≤ Ts - H / S
    · apply dec x (Ts - H / S) hx.1 hr.2 hxr
      intro y hy
      nlinarith [hy.2]
    · apply inc (Ts - H / S) x hr.1 hx.2 (le_of_not_ge hxr)
      intro y hy
      nlinarith [hy.1]
  · intro hS
    by_cases hD : 0 ≤ S * (x - Ts) + H
    · apply le_trans (min_le_left _ _)
      apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      nlinarith [hy.2]
    · apply le_trans (min_le_right _ _)
      apply dec x U hx.1 (le_refl _) hx.2
      intro y hy
      have hh := le_of_not_ge hD
      nlinarith [hy.1]
  · intro hS hH
    apply le_antisymm
    · apply inc L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]
    · apply dec L x (le_refl _) hx.2 hx.1
      intro y hy
      simp [hS, hH]

/- Concrete scenario: 10 g crystalline NaCl at 20 C. Molar mass 58.443
   g/mol (NIST); solvent mass .99820675 kg from 1 L and NIST density.
   PI(con) v and q are linearly interpolated between the published .15
   and .20 mol/kg entries. This is an empirical interpolation, not new data.
   Result: relative apparent molar enthalpy, J/mol, Kelvin used in T². -/
noncomputable def naclRelativeEnthalpy (t : ℝ) : ℝ :=
  let m : ℝ := 10 / (58.443 * 0.99820675)
  let f := (m - 0.15) / 0.05
  let v := (-0.8329 + f * 0.7802) / 1000
  let q := (-60.2 - f * 13.3) / 1000000;
  -(t + 273.15)^2 * (v + 2 * q * t)

/- Integral dissolution energy, joules, at the actual salt/reference
   temperature 20 C. Interpolate Criss-Cobble's 19.97 and 25 C standard
   solid-dissolution data, THEN add the same-temperature relative term. -/
noncomputable def naclDissolutionAt20 : ℝ :=
  (10 / 58.443) *
    (4481 - (20 - 19.97) * 657 / (25 - 19.97) + naclRelativeEnthalpy 20)

/- Effective constant solution-minus-water capacity, J/K, inferred as
   the 20-to-100 C SECANT of the apparent enthalpy with solid salt fixed
   at 20 C. It is NOT the local heat capacity at 25 C.
   Extend the last measured standard-dissolution segment (84.98,95.18 C)
   linearly to 100 C; add solid sensible heat 51 J/(mol K) * 80 K and
   the finite-concentration correction. These extensions/approximations
   are explicit empirical scenario choices, not certified error bounds. -/
noncomputable def naclCapacityChange : ℝ :=
  ((10 / 58.443) *
    (-4540 - (100 - 95.18) * 1318 / (95.18 - 84.98) +
      51 * (100 - 20) + naclRelativeEnthalpy 100) - naclDissolutionAt20) / 80

/- Derived material signs/bounds. No assumed sign for total capacity
   change; these follow from the stated data and interpolation model. -/
lemma nacl_material_inference :
    810 ≤ naclDissolutionAt20 ∧ naclDissolutionAt20 ≤ 820 ∧
    -9 ≤ naclCapacityChange ∧ naclCapacityChange ≤ -8 := by
  norm_num [naclDissolutionAt20, naclCapacityChange, naclRelativeEnthalpy]

/- Physical answer for the chosen case: salt and room at 20 C;
   water+pot effective capacity C>=3900 J/K; atmospheric unsalted
   boiling B0 in [99,100.1] C, brine boiling B in [B0,101] C;
   heater can reach B despite losses. Any addition temperature x from
   the initial 20 C through onset of UNSALTED boiling is allowed.
   Concludes positive total capacity, liquid postmix state (>=19 C),
   increased net power after mixing, and immediate addition minimizes
   time to brine boiling over the WHOLE admissible timing domain. -/
theorem nacl_immediate_addition_answer :
    ∀ (C W k B0 B x : ℝ),
    ((3900 : ℕ) : ℝ) ≤ C → 0 < k → ((99 : ℕ) : ℝ) ≤ B0 → B0 ≤ (((1001 : ℕ) : ℝ) / ((10 : ℕ) : ℝ) : ℝ) →
    B0 ≤ B → B ≤ ((101 : ℕ) : ℝ) → k * (B - initialTemperature) < W →
    x ∈ Set.Icc initialTemperature B0 →
    0 < C + naclCapacityChange ∧
    (((19 : ℕ) : ℝ) ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ∧
      mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x ≤ x) ∧
    (0 < netPower W k initialTemperature x ∧
      netPower W k initialTemperature x <
        netPower W k initialTemperature (mixedTemperature C naclCapacityChange naclDissolutionAt20 initialTemperature x)) ∧
    boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature initialTemperature ≤
      boilingTime C naclCapacityChange naclDissolutionAt20 initialTemperature B W k initialTemperature x := by
  intro C W k B0 B x hC hk hBlo hBhi hB hBmax hW hx
  norm_num only [Nat.cast_ofNat] at hC hBlo hBhi hBmax ⊢
  dsimp only [initialTemperature] at hW ⊢
  obtain ⟨hHlo, hHhi, hSlo, hShi⟩ := nacl_material_inference
  have hc : 0 < C + naclCapacityChange := by linarith
  have hc0 : 0 < C := by linarith
  have hi : initialTemperature = 20 := rfl
  have hcool : ∀ y ∈ Set.Icc initialTemperature B0,
      0 < naclCapacityChange * (y - 20) + naclDissolutionAt20 := by
    intro y hy
    rw [hi] at hy
    have hn : 0 ≤ (naclCapacityChange + 9) * (y - 20) :=
      mul_nonneg (by linarith) (by linarith [hy.1])
    nlinarith [hy.2]
  have hzbelow : ∀ y ∈ Set.Icc initialTemperature B0,
      mixedTemperature C naclCapacityChange naclDissolutionAt20 20 y < y := by
    intro y hy
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 y (ne_of_gt hc)
    have hd := hcool y hy
    nlinarith
  have hz19 : 19 ≤ mixedTemperature C naclCapacityChange naclDissolutionAt20 20 initialTemperature := by
    have hb := mixing_balance C naclCapacityChange naclDissolutionAt20 20 initialTemperature (ne_of_gt hc)
    rw [hi] at hb ⊢
    nlinarith
  have hpowB : 0 < netPower W k 20 B := by unfold netPower; linarith
  have hpow0 : 0 < netPower W k 20 B0 := by
    unfold netPower at *
    nlinarith
  have hdomain : initialTemperature ≤ B0 := by rw [hi]; linarith
  have hzB : mixedTemperature C naclCapacityChange naclDissolutionAt20 20 B0 ≤ B :=
    le_trans (le_of_lt (hzbelow B0 ⟨hdomain, le_refl _⟩)) hB
  have feasible := feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
    19 B0 initialTemperature B0 x hc0 hc hk (by rw [hi]; norm_num)
    (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB hx
  have hj := power_change C naclCapacityChange naclDissolutionAt20 20 W k 20 x (ne_of_gt hc)
  have hjpos : 0 < netPower W k 20 (mixedTemperature C naclCapacityChange naclDissolutionAt20 20 x) - netPower W k 20 x := by
    rw [hj]
    exact div_pos (mul_pos hk (hcool x hx)) hc
  refine ⟨hc, ⟨feasible.2.1.1, le_of_lt (hzbelow x hx)⟩,
    ⟨feasible.2.2.1, by linarith⟩, ?_⟩
  apply time_increasing_on_cooling C naclCapacityChange naclDissolutionAt20 20 B W k 20
    initialTemperature x hc0 hc hk hx.1
  · intro y hy
    exact (feasible_trajectory C naclCapacityChange naclDissolutionAt20 20 B W k 20
      19 B0 initialTemperature B0 y hc0 hc hk (by rw [hi]; norm_num)
      (le_refl _) hdomain (le_refl _) hz19 hzB hpow0 hpowB
      ⟨hy.1, le_trans hy.2 hx.2⟩).2.2
  · intro y hy
    exact le_of_lt (hcool y ⟨hy.1, le_trans hy.2 hx.2⟩)
checks/2abfb9d0c1854fcf943c4d3ecad1151d/submitted.lean
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import Mathlib.Tactic.NormNum

/- Volume in litres, density in g/cm³, result in kg. -/
noncomputable def waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000
noncomputable def saltMoles : ℝ := 10 / 58.443
/- Affine composition coordinate between Parker's measured molalities.
   Affinity in composition is a modeling choice, not a consequence of two rows. -/
noncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)

/- Rational family (a*t+b)/(t+r), identified from three calorimetric
   values. First differences determine r; two equations then give a,b.
   This is an empirical family choice, not a claimed law of electrolytes. -/
noncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=
  let d1 := y25-y20
  let d2 := y30-y25
  let r := (30*d2-20*d1)/(d1-d2)
  let a := (y25*(25+r)-y20*(20+r))/5
  let b := y20*(20+r)-20*a
  (a*t+b)/(t+r)

/- Apparent molar capacity J/(mol K), fitted to Parker table II C.
   Affine composition interpolation and extension to 19..100 C are
   independent empirical choices, not certified consequences of the data. -/
noncomputable def apparentCapacity (t : ℝ) : ℝ :=
  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +
    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)

lemma capacity_formula : ∀ t : ℝ,
    apparentCapacity t =
      4.184*((1-blend)*((-13*t-2314)/(3*t+70)) +
        blend*((2*t-1275)/(t+45))) := by
  intro t
  unfold apparentCapacity calorimetricCurve
  norm_num
  have hratio : (-(13/3*t) + -(2314/3))/(t+70/3) =
      (-(13*t)-2314)/(3*t+70) := by
    field_simp
    <;> ring
  rw [hratio]
  ring

def netPower (W k t : ℝ) : ℝ := W - k * (t - 20)
/- F,G are inverse first-law time primitives for water and brine. -/
noncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=
  F x - F 20 + G B - G (z x)

/- Identification, not hand-picked rational parameters: multiplying
   y=(a*t+b)/(t+r) by its denominator gives a linear identification system.
   These implications uniquely solve that system for both compositions. -/
lemma calorimetric_identification :
    ∀ a b r : ℝ,
    (-19.8)*(20+r)=a*20+b → (-18.2)*(25+r)=a*25+b →
    (-16.9)*(30+r)=a*30+b → a = -13/3 ∧ b = -2314/3 ∧ r = 70/3 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma calorimetric_identification_upper :
    ∀ a b r : ℝ,
    (-19)*(20+r)=a*20+b → (-17.5)*(25+r)=a*25+b →
    (-16.2)*(30+r)=a*30+b → a = 2 ∧ b = -1275 ∧ r = 45 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma composition_inference :
    waterMass = 0.99820675 ∧ 0 < saltMoles ∧ saltMoles < 0.18 ∧
    0 ≤ blend ∧ blend ≤ 1 := by
  norm_num [waterMass, saltMoles, blend]

/- Rigorous bounds on the DECLARED rational family, not measured error bars.
   Two chords bound the concave capacity curves from below. -/
lemma capacity_bounds :
    ∀ t : ℝ, t ∈ Set.Icc 19 100 →
    -100 ≤ apparentCapacity t ∧ apparentCapacity t ≤ 0 ∧
    (25 ≤ t → t ≤ 60 → -77 + (25/35)*(t-25) ≤ apparentCapacity t) ∧
    (60 ≤ t → -52 + (11/40)*(t-60) ≤ apparentCapacity t) := by
  intro t ht
  obtain ⟨hm, hn, hnhi, hw, hw1⟩ := composition_inference
  have hd : 0 < 3*t+70 := by linarith [ht.1]
  have he : 0 < t+45 := by linarith [ht.1]
  have hlo : -100/4.184 ≤ (-13*t-2314)/(3*t+70) := by
    apply (le_div_iff₀ hd).2
    nlinarith [ht.1]
  have hup : -100/4.184 ≤ (2*t-1275)/(t+45) := by
    apply (le_div_iff₀ he).2
    nlinarith [ht.1]
  have hln : (-13*t-2314)/(3*t+70) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.1]) (le_of_lt hd)
  have hun : (2*t-1275)/(t+45) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.2]) (le_of_lt he)
  have combine : ∀ l, l ≤ 4.184*((-13*t-2314)/(3*t+70)) →
      l ≤ 4.184*((2*t-1275)/(t+45)) → l ≤ apparentCapacity t := by
    intro l hl hu
    rw [capacity_formula]
    nlinarith [mul_nonneg (sub_nonneg.mpr hw1) (sub_nonneg.mpr hl),
      mul_nonneg hw (sub_nonneg.mpr hu)]
  refine ⟨combine (-100) (by nlinarith) (by nlinarith), ?_, ?_, ?_⟩
  · rw [capacity_formula]
    nlinarith [mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hw1) hln,
      mul_nonpos_of_nonneg_of_nonpos hw hun]
  · intro h25 h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
  · intro h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith

/- Differential comparison integrates an inequality without assuming
   numerical quadrature or replacing a secant by a local heat capacity. -/
lemma differential_comparison :
    ∀ (f g : ℝ → ℝ) (df dg : ℝ → ℝ) (a b : ℝ), a ≤ b →
    (∀ t ∈ Set.Icc a b, HasDerivAt f (df t) t) →
    (∀ t ∈ Set.Icc a b, HasDerivAt g (dg t) t) →
    (∀ t ∈ Set.Icc a b, dg t ≤ df t) →
    g b - g a ≤ f b - f a := by
  intro f g df dg a b hab hf hg hle
  have hm : MonotoneOn (fun t => f t - g t) (Set.Icc a b) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro t ht; exact ((hf t ht).sub (hg t ht)).continuousAt.continuousWithinAt
    · intro t ht; exact ((hf t (interior_subset ht)).sub (hg t (interior_subset ht))).hasDerivWithinAt
    · intro t ht; exact sub_nonneg.mpr (hle t (interior_subset ht))
  have h := hm ⟨le_rfl,hab⟩ ⟨hab,le_rfl⟩ hab
  linarith

/- d is enthalpy of brine minus original water and stored 20 C solid,
   per mole. I is solid sensible enthalpy 20->25 C. Positivity alone
   suffices: no extrapolated solid Cp or numerical solid integral is used.
   Parker anchor 928 cal/mol + affine finite-composition 87..88 cal/mol.
   d'=absolute apparent capacity is Kirchhoff's law with fixed solid. -/
lemma material_enthalpy_positive :
    ∀ (d : ℝ → ℝ) (I H : ℝ), 0 ≤ I → 923 ≤ H →
    d 25 = 4.184*(H+87+blend)+I →
    (∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t) →
    ∀ t ∈ Set.Icc 20 100, 100 < d t := by
  intro d I H hI hH ha hd t ht
  have hanchor : 4225 ≤ d 25 := by
    have hw := composition_inference.2.2.2.1
    linarith
  have hdec : ∀ a b : ℝ, 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a := by
    intro a b hal hbh hab
    have h := differential_comparison (fun x => -d x) (fun _ => 0)
      (fun x => -apparentCapacity x) (fun _ => 0) a b hab
      (by intro x hx; exact (hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩).neg)
      (by intro x hx; exact hasDerivAt_const x 0)
      (by intro x hx; exact neg_nonneg.mpr (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.1)
    linarith
  have hfirst : d 25 - 2257.5 ≤ d 60 := by
    have h := differential_comparison d
      (fun x => -77*(x-25)+(25/70)*(x-25)^2)
      apparentCapacity (fun x => -77+(25/35)*(x-25)) 25 60 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 25).const_mul (-77) |>.add
            ((((hasDerivAt_id x).sub_const 25).pow 2).const_mul (25/70)) using 1
          · ext v; simp <;> ring
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.1 hx.1 hx.2)
    norm_num at h; linarith
  have hsecond : d 60 - 1860 ≤ d 100 := by
    have h := differential_comparison d
      (fun x => -52*(x-60)+(11/80)*(x-60)^2)
      apparentCapacity (fun x => -52+(11/40)*(x-60)) 60 100 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 60).const_mul (-52) |>.add
            ((((hasDerivAt_id x).sub_const 60).pow 2).const_mul (11/80)) using 1
          · ext v; simp <;> ring
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.2 hx.1)
    norm_num at h; linarith
  have hend := hdec t 100 (by linarith [ht.1]) le_rfl ht.2
  linarith

/- The shared loss law derives a power change from the mixing jump;
   no independent before/after heating powers are introduced. -/
lemma newtonian_power_change : ∀ W k x z : ℝ,
    netPower W k z - netPower W k x = k*(x-z) := by
  intro W k x z
  unfold netPower
  ring

/- Variable component storage, J/K: liquid-water specific Cp cw in
   J/(kg K), plus nonnegative pot capacity p in J/K. -/
noncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=
  waterMass * cw t + p t

/- Scientific conclusion. All thermodynamic and first-law premises are
   visible. z is the differentiable, liquid-valued mixing solution;
   its existence/phase admissibility is an exposed physical guard.
   No boiling dwell is allowed: addition x ends at pure-water onset B0.
   The recommendation is conditional on the empirical rational family,
   its composition interpolation and its full-temperature applicability. -/
theorem salt_timing_answer :
    ∀ (U V cw p F G z : ℝ → ℝ) (K I H W k B0 B x : ℝ),
    0 ≤ I → 923 ≤ H → H ≤ 933 →
    V 25 - U 25 - K = saltMoles * (4.184*(H+87+blend)+I) →
    (∀ t ∈ Set.Icc 19 100, 4000 ≤ cw t ∧ 0 ≤ p t) →
    (∀ t ∈ Set.Icc 19 100, HasDerivAt U (waterCapacity cw p t) t) →
    (∀ t ∈ Set.Icc 19 100,
      HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) →
    20 ≤ B0 → B0 ≤ B → B ≤ 100 → 0 < k → k*(B-20) < W →
    (∀ y, V (z y) = U y + K) →
    (∀ y ∈ Set.Icc 20 B0, z y ∈ Set.Icc 19 B ∧ DifferentiableAt ℝ z y) →
    (∀ t ∈ Set.Icc 19 B,
      HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
      HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) /
        netPower W k t) t) →
    x ∈ Set.Icc 20 B0 →
    z x < x ∧
    netPower W k (z x) - netPower W k x = k*(x-z x) ∧
    netPower W k x < netPower W k (z x) ∧
    totalTime F G z B 20 ≤ totalTime F G z B x := by
  intro U V cw p F G z K I H W k B0 B x hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx
  obtain ⟨hmass, hn, hnhi, hw, hw1⟩ := composition_inference
  have hN : saltMoles ≠ 0 := ne_of_gt hn
  have hstorage : ∀ t ∈ Set.Icc 19 100,
      0 < waterCapacity cw p t ∧
      0 < waterCapacity cw p t + saltMoles * apparentCapacity t := by
    intro t ht
    obtain ⟨hcw, hp⟩ := hcomponents t ht
    have hcp := (capacity_bounds t ht).1
    have hbound := mul_nonneg (le_of_lt hn) (show 0 ≤ apparentCapacity t + 100 by linarith)
    unfold waterCapacity
    rw [hmass]
    constructor <;> nlinarith
  have hd : ∀ t ∈ Set.Icc 20 100,
      100 < (V t - U t - K) / saltMoles := by
    apply material_enthalpy_positive (fun t => (V t-U t-K)/saltMoles) I H hI hH
    · rw [ha]; field_simp
    · intro t ht
      convert (((hV t ht).sub (hU t ht)).sub_const K).div_const saltMoles using 1
      field_simp
      ring
  have hVm : StrictMonoOn V (Set.Icc 19 100) := by
    apply strictMonoOn_of_hasDerivWithinAt_pos (convex_Icc _ _)
    · intro t ht; exact (hV t ht).continuousAt.continuousWithinAt
    · intro t ht; exact (hV t (interior_subset ht)).hasDerivWithinAt
    · intro t ht; exact (hstorage t (interior_subset ht)).2
  have hcool : ∀ y ∈ Set.Icc 20 B0, z y < y := by
    intro y hy
    have hy100 : y ∈ Set.Icc 19 100 := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨(hz y hy).1.1,by linarith [(hz y hy).1.2]⟩
    have hdpos := (lt_div_iff₀ hn).1 (hd y ⟨hy.1,by linarith [hy.2]⟩)
    by_contra h
    have hle : V y ≤ V (z y) := hVm.monotoneOn hy100 hz100 (le_of_not_gt h)
    rw [hmix y] at hle
    nlinarith
  have hpower : ∀ t ∈ Set.Icc 19 B, 0 < netPower W k t := by
    intro t ht
    unfold netPower
    nlinarith [ht.2]
  have hder : ∀ y ∈ Set.Icc 20 B0,
      HasDerivAt (totalTime F G z B)
        (waterCapacity cw p y *
          (1 / netPower W k y - 1 / netPower W k (z y))) y := by
    intro y hy
    have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hy100 : y ∈ Set.Icc 19 100 := ⟨hyB.1,by linarith [hyB.2]⟩
    have hzB := (hz y hy).1
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨hzB.1,by linarith [hzB.2]⟩
    have hchain := (hV (z y) hz100).comp y (hz y hy).2.hasDerivAt
    have hid : (fun t => V (z t)) = (fun t => U t + K) := funext hmix
    change HasDerivAt (fun t => V (z t)) _ y at hchain
    rw [hid] at hchain
    have he := hchain.unique ((hU y hy100).add_const K)
    have ht := (((hFG y hyB).1.sub_const (F 20)).add_const (G B)).sub
      ((hFG (z y) hzB).2.comp y (hz y hy).2.hasDerivAt)
    change HasDerivAt (totalTime F G z B) _ y at ht
    convert ht using 1
    have hny := ne_of_gt (hpower y hyB)
    have hnz := ne_of_gt (hpower (z y) hzB)
    field_simp [hny, hnz]
    have he' := congrArg (fun a : ℝ => netPower W k y * a) he
    nlinarith only [he']
  have hmon : MonotoneOn (totalTime F G z B) (Set.Icc 20 B0) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy; exact (hder y hy).continuousAt.continuousWithinAt
    · intro y hy; exact (hder y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hyI := interior_subset hy
      have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hyI.1],by linarith [hyI.2]⟩
      have hny := hpower y hyB
      have hnz := hpower (z y) (hz y hyI).1
      have horder : netPower W k y ≤ netPower W k (z y) := by
        unfold netPower; nlinarith [hcool y hyI]
      have hrecip : 1 / netPower W k (z y) ≤ 1 / netPower W k y :=
        one_div_le_one_div_of_le hny horder
      exact mul_nonneg (le_of_lt (hstorage y ⟨hyB.1,by linarith [hyB.2]⟩).1)
        (sub_nonneg.mpr hrecip)
  refine ⟨hcool x hx, newtonian_power_change W k x (z x), ?_,
    hmon ⟨le_rfl,hB0⟩ hx hx.1⟩
  unfold netPower
  nlinarith [hcool x hx]
checks/827f88bd852b4d06a3f5f893832d7056/submitted.lean
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import Mathlib.Tactic.NormNum

/- Volume in litres, density in g/cm³, result in kg. -/
noncomputable def waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000
noncomputable def saltMoles : ℝ := 10 / 58.443
/- Affine composition coordinate between Parker's measured molalities.
   Affinity in composition is a modeling choice, not a consequence of two rows. -/
noncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)

/- Rational family (a*t+b)/(t+r), identified from three calorimetric
   values. First differences determine r; two equations then give a,b.
   This is an empirical family choice, not a claimed law of electrolytes. -/
noncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=
  let d1 := y25-y20
  let d2 := y30-y25
  let r := (30*d2-20*d1)/(d1-d2)
  let a := (y25*(25+r)-y20*(20+r))/5
  let b := y20*(20+r)-20*a
  (a*t+b)/(t+r)

/- Apparent molar capacity J/(mol K), fitted to Parker table II C.
   Affine composition interpolation and extension to 19..100 C are
   independent empirical choices, not certified consequences of the data. -/
noncomputable def apparentCapacity (t : ℝ) : ℝ :=
  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +
    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)

lemma capacity_formula : ∀ t : ℝ,
    apparentCapacity t =
      4.184*((1-blend)*((-13*t-2314)/(3*t+70)) +
        blend*((2*t-1275)/(t+45))) := by
  intro t
  unfold apparentCapacity calorimetricCurve
  norm_num
  have hratio : (-(13/3*t) + -(2314/3))/(t+70/3) =
      (-(13*t)-2314)/(3*t+70) := by
    field_simp
    <;> ring
  rw [hratio]
  ring

def netPower (W k t : ℝ) : ℝ := W - k * (t - 20)
/- F,G are inverse first-law time primitives for water and brine. -/
noncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=
  F x - F 20 + G B - G (z x)

/- Identification, not hand-picked rational parameters: multiplying
   y=(a*t+b)/(t+r) by its denominator gives a linear identification system.
   These implications uniquely solve that system for both compositions. -/
lemma calorimetric_identification :
    ∀ a b r : ℝ,
    (-19.8)*(20+r)=a*20+b → (-18.2)*(25+r)=a*25+b →
    (-16.9)*(30+r)=a*30+b → a = -13/3 ∧ b = -2314/3 ∧ r = 70/3 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma calorimetric_identification_upper :
    ∀ a b r : ℝ,
    (-19)*(20+r)=a*20+b → (-17.5)*(25+r)=a*25+b →
    (-16.2)*(30+r)=a*30+b → a = 2 ∧ b = -1275 ∧ r = 45 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma composition_inference :
    waterMass = 0.99820675 ∧ 0 < saltMoles ∧ saltMoles < 0.18 ∧
    0 ≤ blend ∧ blend ≤ 1 := by
  norm_num [waterMass, saltMoles, blend]

/- Rigorous bounds on the DECLARED rational family, not measured error bars.
   Two chords bound the concave capacity curves from below. -/
lemma capacity_bounds :
    ∀ t : ℝ, t ∈ Set.Icc 19 100 →
    -100 ≤ apparentCapacity t ∧ apparentCapacity t ≤ 0 ∧
    (25 ≤ t → t ≤ 60 → -77 + (25/35)*(t-25) ≤ apparentCapacity t) ∧
    (60 ≤ t → -52 + (11/40)*(t-60) ≤ apparentCapacity t) := by
  intro t ht
  obtain ⟨hm, hn, hnhi, hw, hw1⟩ := composition_inference
  have hd : 0 < 3*t+70 := by linarith [ht.1]
  have he : 0 < t+45 := by linarith [ht.1]
  have hlo : -100/4.184 ≤ (-13*t-2314)/(3*t+70) := by
    apply (le_div_iff₀ hd).2
    nlinarith [ht.1]
  have hup : -100/4.184 ≤ (2*t-1275)/(t+45) := by
    apply (le_div_iff₀ he).2
    nlinarith [ht.1]
  have hln : (-13*t-2314)/(3*t+70) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.1]) (le_of_lt hd)
  have hun : (2*t-1275)/(t+45) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.2]) (le_of_lt he)
  have combine : ∀ l, l ≤ 4.184*((-13*t-2314)/(3*t+70)) →
      l ≤ 4.184*((2*t-1275)/(t+45)) → l ≤ apparentCapacity t := by
    intro l hl hu
    rw [capacity_formula]
    nlinarith [mul_nonneg (sub_nonneg.mpr hw1) (sub_nonneg.mpr hl),
      mul_nonneg hw (sub_nonneg.mpr hu)]
  refine ⟨combine (-100) (by nlinarith) (by nlinarith), ?_, ?_, ?_⟩
  · rw [capacity_formula]
    nlinarith [mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hw1) hln,
      mul_nonpos_of_nonneg_of_nonpos hw hun]
  · intro h25 h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
  · intro h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith

/- Differential comparison integrates an inequality without assuming
   numerical quadrature or replacing a secant by a local heat capacity. -/
lemma differential_comparison :
    ∀ (f g : ℝ → ℝ) (df dg : ℝ → ℝ) (a b : ℝ), a ≤ b →
    (∀ t ∈ Set.Icc a b, HasDerivAt f (df t) t) →
    (∀ t ∈ Set.Icc a b, HasDerivAt g (dg t) t) →
    (∀ t ∈ Set.Icc a b, dg t ≤ df t) →
    g b - g a ≤ f b - f a := by
  intro f g df dg a b hab hf hg hle
  have hm : MonotoneOn (fun t => f t - g t) (Set.Icc a b) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro t ht; exact ((hf t ht).sub (hg t ht)).continuousAt.continuousWithinAt
    · intro t ht; exact ((hf t (interior_subset ht)).sub (hg t (interior_subset ht))).hasDerivWithinAt
    · intro t ht; exact sub_nonneg.mpr (hle t (interior_subset ht))
  have h := hm ⟨le_rfl,hab⟩ ⟨hab,le_rfl⟩ hab
  linarith

/- d is enthalpy of brine minus original water and stored 20 C solid,
   per mole. I is solid sensible enthalpy 20->25 C. Positivity alone
   suffices: no extrapolated solid Cp or numerical solid integral is used.
   Parker anchor 928 cal/mol + affine finite-composition 87..88 cal/mol.
   d'=absolute apparent capacity is Kirchhoff's law with fixed solid. -/
lemma material_enthalpy_positive :
    ∀ (d : ℝ → ℝ) (I H : ℝ), 0 ≤ I → 923 ≤ H →
    d 25 = 4.184*(H+87+blend)+I →
    (∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t) →
    ∀ t ∈ Set.Icc 20 100, 100 < d t := by
  intro d I H hI hH ha hd t ht
  have hanchor : 4225 ≤ d 25 := by
    have hw := composition_inference.2.2.2.1
    linarith
  have hdec : ∀ a b : ℝ, 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a := by
    intro a b hal hbh hab
    have h := differential_comparison (fun x => -d x) (fun _ => 0)
      (fun x => -apparentCapacity x) (fun _ => 0) a b hab
      (by intro x hx; exact (hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩).neg)
      (by intro x hx; exact hasDerivAt_const x 0)
      (by intro x hx; exact neg_nonneg.mpr (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.1)
    linarith
  have hfirst : d 25 - 2257.5 ≤ d 60 := by
    have h := differential_comparison d
      (fun x => -77*(x-25)+(25/70)*(x-25)^2)
      apparentCapacity (fun x => -77+(25/35)*(x-25)) 25 60 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 25).const_mul (-77) |>.add
            ((((hasDerivAt_id x).sub_const 25).pow 2).const_mul (25/70)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.1 hx.1 hx.2)
    norm_num at h; linarith
  have hsecond : d 60 - 1860 ≤ d 100 := by
    have h := differential_comparison d
      (fun x => -52*(x-60)+(11/80)*(x-60)^2)
      apparentCapacity (fun x => -52+(11/40)*(x-60)) 60 100 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 60).const_mul (-52) |>.add
            ((((hasDerivAt_id x).sub_const 60).pow 2).const_mul (11/80)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.2 hx.1)
    norm_num at h; linarith
  have hend := hdec t 100 (by linarith [ht.1]) le_rfl ht.2
  linarith

/- The shared loss law derives a power change from the mixing jump;
   no independent before/after heating powers are introduced. -/
lemma newtonian_power_change : ∀ W k x z : ℝ,
    netPower W k z - netPower W k x = k*(x-z) := by
  intro W k x z
  unfold netPower
  ring

/- Variable component storage, J/K: liquid-water specific Cp cw in
   J/(kg K), plus nonnegative pot capacity p in J/K. -/
noncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=
  waterMass * cw t + p t

/- Scientific conclusion. All thermodynamic and first-law premises are
   visible. z is the differentiable, liquid-valued mixing solution;
   its existence/phase admissibility is an exposed physical guard.
   No boiling dwell is allowed: addition x ends at pure-water onset B0.
   The recommendation is conditional on the empirical rational family,
   its composition interpolation and its full-temperature applicability. -/
theorem salt_timing_answer :
    ∀ (U V cw p F G z : ℝ → ℝ) (K I H W k B0 B x : ℝ),
    ((0 : ℕ) : ℝ) ≤ I → ((923 : ℕ) : ℝ) ≤ H → H ≤ ((933 : ℕ) : ℝ) →
    V ((25 : ℕ) : ℝ) - U ((25 : ℕ) : ℝ) - K = saltMoles * (4.184*(H+((87 : ℕ) : ℝ)+blend)+I) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), ((4000 : ℕ) : ℝ) ≤ cw t ∧ ((0 : ℕ) : ℝ) ≤ p t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), HasDerivAt U (waterCapacity cw p t) t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ),
      HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) →
    ((20 : ℕ) : ℝ) ≤ B0 → B0 ≤ B → B ≤ ((100 : ℕ) : ℝ) → ((0 : ℕ) : ℝ) < k → k*(B-((20 : ℕ) : ℝ)) < W →
    (∀ y, V (z y) = U y + K) →
    (∀ y ∈ Set.Icc ((20 : ℕ) : ℝ) B0, z y ∈ Set.Icc ((19 : ℕ) : ℝ) B ∧ DifferentiableAt ℝ z y) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) B,
      HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
      HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) /
        netPower W k t) t) →
    x ∈ Set.Icc ((20 : ℕ) : ℝ) B0 →
    z x < x ∧
    netPower W k (z x) - netPower W k x = k*(x-z x) ∧
    netPower W k x < netPower W k (z x) ∧
    totalTime F G z B ((20 : ℕ) : ℝ) ≤ totalTime F G z B x := by
  intro U V cw p F G z K I H W k B0 B x hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx
  norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV hB0 hB0B hB hk hW hmix hz hFG hx ⊢
  obtain ⟨hmass, hn, hnhi, hw, hw1⟩ := composition_inference
  have hN : saltMoles ≠ 0 := ne_of_gt hn
  have hstorage : ∀ t ∈ Set.Icc 19 100,
      0 < waterCapacity cw p t ∧
      0 < waterCapacity cw p t + saltMoles * apparentCapacity t := by
    intro t ht
    obtain ⟨hcw, hp⟩ := hcomponents t ht
    have hcp := (capacity_bounds t ht).1
    have hbound := mul_nonneg (le_of_lt hn) (show 0 ≤ apparentCapacity t + 100 by linarith)
    unfold waterCapacity
    rw [hmass]
    constructor <;> nlinarith
  have hd : ∀ t ∈ Set.Icc 20 100,
      100 < (V t - U t - K) / saltMoles := by
    apply material_enthalpy_positive (fun t => (V t-U t-K)/saltMoles) I H hI hH
    · rw [ha]; field_simp
    · intro t ht
      convert (((hV t ht).sub (hU t ht)).sub_const K).div_const saltMoles using 1
      field_simp
      ring
  have hVm : StrictMonoOn V (Set.Icc 19 100) := by
    apply strictMonoOn_of_hasDerivWithinAt_pos (convex_Icc _ _)
    · intro t ht; exact (hV t ht).continuousAt.continuousWithinAt
    · intro t ht; exact (hV t (interior_subset ht)).hasDerivWithinAt
    · intro t ht; exact (hstorage t (interior_subset ht)).2
  have hcool : ∀ y ∈ Set.Icc 20 B0, z y < y := by
    intro y hy
    have hy100 : y ∈ Set.Icc 19 100 := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨(hz y hy).1.1,by linarith [(hz y hy).1.2]⟩
    have hdpos := (lt_div_iff₀ hn).1 (hd y ⟨hy.1,by linarith [hy.2]⟩)
    by_contra h
    have hle : V y ≤ V (z y) := hVm.monotoneOn hy100 hz100 (le_of_not_gt h)
    rw [hmix y] at hle
    nlinarith
  have hpower : ∀ t ∈ Set.Icc 19 B, 0 < netPower W k t := by
    intro t ht
    unfold netPower
    nlinarith [ht.2]
  have hder : ∀ y ∈ Set.Icc 20 B0,
      HasDerivAt (totalTime F G z B)
        (waterCapacity cw p y *
          (1 / netPower W k y - 1 / netPower W k (z y))) y := by
    intro y hy
    have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hy100 : y ∈ Set.Icc 19 100 := ⟨hyB.1,by linarith [hyB.2]⟩
    have hzB := (hz y hy).1
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨hzB.1,by linarith [hzB.2]⟩
    have hchain := (hV (z y) hz100).comp y (hz y hy).2.hasDerivAt
    have hid : (fun t => V (z t)) = (fun t => U t + K) := funext hmix
    change HasDerivAt (fun t => V (z t)) _ y at hchain
    rw [hid] at hchain
    have he := hchain.unique ((hU y hy100).add_const K)
    have ht := (((hFG y hyB).1.sub_const (F 20)).add_const (G B)).sub
      ((hFG (z y) hzB).2.comp y (hz y hy).2.hasDerivAt)
    change HasDerivAt (totalTime F G z B) _ y at ht
    convert ht using 1
    have hny := ne_of_gt (hpower y hyB)
    have hnz := ne_of_gt (hpower (z y) hzB)
    field_simp [hny, hnz]
    have he' := congrArg (fun a : ℝ => netPower W k y * a) he
    nlinarith only [he']
  have hmon : MonotoneOn (totalTime F G z B) (Set.Icc 20 B0) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy; exact (hder y hy).continuousAt.continuousWithinAt
    · intro y hy; exact (hder y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hyI := interior_subset hy
      have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hyI.1],by linarith [hyI.2]⟩
      have hny := hpower y hyB
      have hnz := hpower (z y) (hz y hyI).1
      have horder : netPower W k y ≤ netPower W k (z y) := by
        unfold netPower; nlinarith [hcool y hyI]
      have hrecip : 1 / netPower W k (z y) ≤ 1 / netPower W k y :=
        one_div_le_one_div_of_le hny horder
      exact mul_nonneg (le_of_lt (hstorage y ⟨hyB.1,by linarith [hyB.2]⟩).1)
        (sub_nonneg.mpr hrecip)
  refine ⟨hcool x hx, newtonian_power_change W k x (z x), ?_,
    hmon ⟨le_rfl,hB0⟩ hx hx.1⟩
  unfold netPower
  nlinarith [hcool x hx]
checks/b140062e8fd043a79dde530ae0be409e/submitted.lean
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import Mathlib.Tactic.NormNum

/- Volume in litres, density in g/cm³, result in kg. -/
noncomputable def waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000
noncomputable def saltMoles : ℝ := 10 / 58.443
/- Affine composition coordinate between Parker's measured molalities.
   Affinity in composition is a modeling choice, not a consequence of two rows. -/
noncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)

/- Rational family (a*t+b)/(t+r), identified from three calorimetric
   values. First differences determine r; two equations then give a,b.
   This is an empirical family choice, not a claimed law of electrolytes. -/
noncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=
  let d1 := y25-y20
  let d2 := y30-y25
  let r := (30*d2-20*d1)/(d1-d2)
  let a := (y25*(25+r)-y20*(20+r))/5
  let b := y20*(20+r)-20*a
  (a*t+b)/(t+r)

/- Apparent molar capacity J/(mol K), fitted to Parker table II C.
   Affine composition interpolation and extension to 19..100 C are
   independent empirical choices, not certified consequences of the data. -/
noncomputable def apparentCapacity (t : ℝ) : ℝ :=
  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +
    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)

lemma capacity_formula : ∀ t : ℝ,
    apparentCapacity t =
      4.184*((1-blend)*((-13*t-2314)/(3*t+70)) +
        blend*((2*t-1275)/(t+45))) := by
  intro t
  unfold apparentCapacity calorimetricCurve
  norm_num
  have hratio : (-(13/3*t) + -(2314/3))/(t+70/3) =
      (-(13*t)-2314)/(3*t+70) := by
    field_simp
    <;> ring
  rw [hratio]
  ring

def netPower (W k t : ℝ) : ℝ := W - k * (t - 20)
/- F,G are inverse first-law time primitives for water and brine. -/
noncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=
  F x - F 20 + G B - G (z x)

/- Identification, not hand-picked rational parameters: multiplying
   y=(a*t+b)/(t+r) by its denominator gives a linear identification system.
   These implications uniquely solve that system for both compositions. -/
lemma calorimetric_identification :
    ∀ a b r : ℝ,
    (-19.8)*(20+r)=a*20+b → (-18.2)*(25+r)=a*25+b →
    (-16.9)*(30+r)=a*30+b → a = -13/3 ∧ b = -2314/3 ∧ r = 70/3 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma calorimetric_identification_upper :
    ∀ a b r : ℝ,
    (-19)*(20+r)=a*20+b → (-17.5)*(25+r)=a*25+b →
    (-16.2)*(30+r)=a*30+b → a = 2 ∧ b = -1275 ∧ r = 45 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma composition_inference :
    waterMass = 0.99820675 ∧ 0 < saltMoles ∧ saltMoles < 0.18 ∧
    0 ≤ blend ∧ blend ≤ 1 := by
  norm_num [waterMass, saltMoles, blend]

/- Rigorous bounds on the DECLARED rational family, not measured error bars.
   Two chords bound the concave capacity curves from below. -/
lemma capacity_bounds :
    ∀ t : ℝ, t ∈ Set.Icc 19 100 →
    -100 ≤ apparentCapacity t ∧ apparentCapacity t ≤ 0 ∧
    (25 ≤ t → t ≤ 60 → -77 + (25/35)*(t-25) ≤ apparentCapacity t) ∧
    (60 ≤ t → -52 + (11/40)*(t-60) ≤ apparentCapacity t) := by
  intro t ht
  obtain ⟨hm, hn, hnhi, hw, hw1⟩ := composition_inference
  have hd : 0 < 3*t+70 := by linarith [ht.1]
  have he : 0 < t+45 := by linarith [ht.1]
  have hlo : -100/4.184 ≤ (-13*t-2314)/(3*t+70) := by
    apply (le_div_iff₀ hd).2
    nlinarith [ht.1]
  have hup : -100/4.184 ≤ (2*t-1275)/(t+45) := by
    apply (le_div_iff₀ he).2
    nlinarith [ht.1]
  have hln : (-13*t-2314)/(3*t+70) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.1]) (le_of_lt hd)
  have hun : (2*t-1275)/(t+45) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.2]) (le_of_lt he)
  have combine : ∀ l, l ≤ 4.184*((-13*t-2314)/(3*t+70)) →
      l ≤ 4.184*((2*t-1275)/(t+45)) → l ≤ apparentCapacity t := by
    intro l hl hu
    rw [capacity_formula]
    nlinarith [mul_nonneg (sub_nonneg.mpr hw1) (sub_nonneg.mpr hl),
      mul_nonneg hw (sub_nonneg.mpr hu)]
  refine ⟨combine (-100) (by nlinarith) (by nlinarith), ?_, ?_, ?_⟩
  · rw [capacity_formula]
    nlinarith [mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hw1) hln,
      mul_nonpos_of_nonneg_of_nonpos hw hun]
  · intro h25 h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
  · intro h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith

/- Differential comparison integrates an inequality without assuming
   numerical quadrature or replacing a secant by a local heat capacity. -/
lemma differential_comparison :
    ∀ (f g : ℝ → ℝ) (df dg : ℝ → ℝ) (a b : ℝ), a ≤ b →
    (∀ t ∈ Set.Icc a b, HasDerivAt f (df t) t) →
    (∀ t ∈ Set.Icc a b, HasDerivAt g (dg t) t) →
    (∀ t ∈ Set.Icc a b, dg t ≤ df t) →
    g b - g a ≤ f b - f a := by
  intro f g df dg a b hab hf hg hle
  have hm : MonotoneOn (fun t => f t - g t) (Set.Icc a b) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro t ht; exact ((hf t ht).sub (hg t ht)).continuousAt.continuousWithinAt
    · intro t ht; exact ((hf t (interior_subset ht)).sub (hg t (interior_subset ht))).hasDerivWithinAt
    · intro t ht; exact sub_nonneg.mpr (hle t (interior_subset ht))
  have h := hm ⟨le_rfl,hab⟩ ⟨hab,le_rfl⟩ hab
  linarith

/- d is enthalpy of brine minus original water and stored 20 C solid,
   per mole. I is solid sensible enthalpy 20->25 C. Positivity alone
   suffices: no extrapolated solid Cp or numerical solid integral is used.
   Parker anchor 928 cal/mol + affine finite-composition 87..88 cal/mol.
   d'=absolute apparent capacity is Kirchhoff's law with fixed solid. -/
lemma material_enthalpy_positive :
    ∀ (d : ℝ → ℝ) (I H : ℝ), 0 ≤ I → 923 ≤ H →
    d 25 = 4.184*(H+87+blend)+I →
    (∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t) →
    ∀ t ∈ Set.Icc 20 100, 100 < d t := by
  intro d I H hI hH ha hd t ht
  have hanchor : 4225 ≤ d 25 := by
    have hw := composition_inference.2.2.2.1
    linarith
  have hdec : ∀ a b : ℝ, 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a := by
    intro a b hal hbh hab
    have h := differential_comparison (fun x => -d x) (fun _ => 0)
      (fun x => -apparentCapacity x) (fun _ => 0) a b hab
      (by intro x hx; exact (hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩).neg)
      (by intro x hx; exact hasDerivAt_const x 0)
      (by intro x hx; exact neg_nonneg.mpr (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.1)
    linarith
  have hfirst : d 25 - 2257.5 ≤ d 60 := by
    have h := differential_comparison d
      (fun x => -77*(x-25)+(25/70)*(x-25)^2)
      apparentCapacity (fun x => -77+(25/35)*(x-25)) 25 60 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 25).const_mul (-77) |>.add
            ((((hasDerivAt_id x).sub_const 25).pow 2).const_mul (25/70)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.1 hx.1 hx.2)
    norm_num at h; linarith
  have hsecond : d 60 - 1860 ≤ d 100 := by
    have h := differential_comparison d
      (fun x => -52*(x-60)+(11/80)*(x-60)^2)
      apparentCapacity (fun x => -52+(11/40)*(x-60)) 60 100 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 60).const_mul (-52) |>.add
            ((((hasDerivAt_id x).sub_const 60).pow 2).const_mul (11/80)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.2 hx.1)
    norm_num at h; linarith
  have hend := hdec t 100 (by linarith [ht.1]) le_rfl ht.2
  linarith

/- The shared loss law derives a power change from the mixing jump;
   no independent before/after heating powers are introduced. -/
lemma newtonian_power_change : ∀ W k x z : ℝ,
    netPower W k z - netPower W k x = k*(x-z) := by
  intro W k x z
  unfold netPower
  ring

/- Variable component storage, J/K: liquid-water specific Cp cw in
   J/(kg K), plus nonnegative pot capacity p in J/K. -/
noncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=
  waterMass * cw t + p t

/- Scientific conclusion. All thermodynamic and first-law premises are
   visible. z is the differentiable, liquid-valued mixing solution;
   its existence/phase admissibility is an exposed physical guard.
   No boiling dwell is allowed: addition x ends at pure-water onset B0.
   The recommendation is conditional on the empirical rational family,
   its composition interpolation and its full-temperature applicability. -/
theorem salt_timing_answer :
    ∀ (U V cw p F G z : ℝ → ℝ) (K I H W k B0 B x : ℝ),
    ((0 : ℕ) : ℝ) ≤ I → ((923 : ℕ) : ℝ) ≤ H → H ≤ ((933 : ℕ) : ℝ) →
    V ((25 : ℕ) : ℝ) - U ((25 : ℕ) : ℝ) - K = saltMoles * (4.184*(H+((87 : ℕ) : ℝ)+blend)+I) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), ((4000 : ℕ) : ℝ) ≤ cw t ∧ ((0 : ℕ) : ℝ) ≤ p t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), HasDerivAt U (waterCapacity cw p t) t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ),
      HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) →
    ((20 : ℕ) : ℝ) ≤ B0 → B0 ≤ B → B ≤ ((100 : ℕ) : ℝ) → ((0 : ℕ) : ℝ) < k → k*(B-((20 : ℕ) : ℝ)) < W →
    (∀ y, V (z y) = U y + K) →
    (∀ y ∈ Set.Icc ((20 : ℕ) : ℝ) B0, z y ∈ Set.Icc ((19 : ℕ) : ℝ) B ∧ DifferentiableAt ℝ z y) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) B,
      HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
      HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) /
        netPower W k t) t) →
    x ∈ Set.Icc ((20 : ℕ) : ℝ) B0 →
    z x < x ∧
    netPower W k (z x) - netPower W k x = k*(x-z x) ∧
    netPower W k x < netPower W k (z x) ∧
    totalTime F G z B ((20 : ℕ) : ℝ) ≤ totalTime F G z B x := by
  intro U V cw p F G z K I H W k B0 B x hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx
  norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx ⊢
  obtain ⟨hmass, hn, hnhi, hw, hw1⟩ := composition_inference
  have hN : saltMoles ≠ 0 := ne_of_gt hn
  have hstorage : ∀ t ∈ Set.Icc 19 100,
      0 < waterCapacity cw p t ∧
      0 < waterCapacity cw p t + saltMoles * apparentCapacity t := by
    intro t ht
    obtain ⟨hcw, hp⟩ := hcomponents t ht
    have hcp := (capacity_bounds t ht).1
    have hbound := mul_nonneg (le_of_lt hn) (show 0 ≤ apparentCapacity t + 100 by linarith)
    unfold waterCapacity
    rw [hmass]
    constructor <;> nlinarith
  have hd : ∀ t ∈ Set.Icc 20 100,
      100 < (V t - U t - K) / saltMoles := by
    apply material_enthalpy_positive (fun t => (V t-U t-K)/saltMoles) I H hI hH
    · rw [ha]; field_simp
    · intro t ht
      convert (((hV t ht).sub (hU t ht)).sub_const K).div_const saltMoles using 1
      field_simp
      ring
  have hVm : StrictMonoOn V (Set.Icc 19 100) := by
    apply strictMonoOn_of_hasDerivWithinAt_pos (convex_Icc _ _)
    · intro t ht; exact (hV t ht).continuousAt.continuousWithinAt
    · intro t ht; exact (hV t (interior_subset ht)).hasDerivWithinAt
    · intro t ht; exact (hstorage t (interior_subset ht)).2
  have hcool : ∀ y ∈ Set.Icc 20 B0, z y < y := by
    intro y hy
    have hy100 : y ∈ Set.Icc 19 100 := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨(hz y hy).1.1,by linarith [(hz y hy).1.2]⟩
    have hdpos := (lt_div_iff₀ hn).1 (hd y ⟨hy.1,by linarith [hy.2]⟩)
    by_contra h
    have hle : V y ≤ V (z y) := hVm.monotoneOn hy100 hz100 (le_of_not_gt h)
    rw [hmix y] at hle
    nlinarith
  have hpower : ∀ t ∈ Set.Icc 19 B, 0 < netPower W k t := by
    intro t ht
    unfold netPower
    nlinarith [ht.2]
  have hder : ∀ y ∈ Set.Icc 20 B0,
      HasDerivAt (totalTime F G z B)
        (waterCapacity cw p y *
          (1 / netPower W k y - 1 / netPower W k (z y))) y := by
    intro y hy
    have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hy100 : y ∈ Set.Icc 19 100 := ⟨hyB.1,by linarith [hyB.2]⟩
    have hzB := (hz y hy).1
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨hzB.1,by linarith [hzB.2]⟩
    have hchain := (hV (z y) hz100).comp y (hz y hy).2.hasDerivAt
    have hid : (fun t => V (z t)) = (fun t => U t + K) := funext hmix
    change HasDerivAt (fun t => V (z t)) _ y at hchain
    rw [hid] at hchain
    have he := hchain.unique ((hU y hy100).add_const K)
    have ht := (((hFG y hyB).1.sub_const (F 20)).add_const (G B)).sub
      ((hFG (z y) hzB).2.comp y (hz y hy).2.hasDerivAt)
    change HasDerivAt (totalTime F G z B) _ y at ht
    convert ht using 1
    have hny := ne_of_gt (hpower y hyB)
    have hnz := ne_of_gt (hpower (z y) hzB)
    field_simp [hny, hnz]
    have he' := congrArg (fun a : ℝ => netPower W k y * a) he
    nlinarith only [he']
  have hmon : MonotoneOn (totalTime F G z B) (Set.Icc 20 B0) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy; exact (hder y hy).continuousAt.continuousWithinAt
    · intro y hy; exact (hder y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hyI := interior_subset hy
      have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hyI.1],by linarith [hyI.2]⟩
      have hny := hpower y hyB
      have hnz := hpower (z y) (hz y hyI).1
      have horder : netPower W k y ≤ netPower W k (z y) := by
        unfold netPower; nlinarith [hcool y hyI]
      have hrecip : 1 / netPower W k (z y) ≤ 1 / netPower W k y :=
        one_div_le_one_div_of_le hny horder
      exact mul_nonneg (le_of_lt (hstorage y ⟨hyB.1,by linarith [hyB.2]⟩).1)
        (sub_nonneg.mpr hrecip)
  refine ⟨hcool x hx, newtonian_power_change W k x (z x), ?_,
    hmon ⟨le_rfl,hB0⟩ hx hx.1⟩
  unfold netPower
  nlinarith [hcool x hx]
checks/b352fb73609c49c88d1352895ad763d1/submitted.lean
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import Mathlib.Tactic.NormNum

/- Volume in litres, density in g/cm³, result in kg. -/
noncomputable def waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000
noncomputable def saltMoles : ℝ := 10 / 58.443
/- Affine composition coordinate between Parker's measured molalities.
   Affinity in composition is a modeling choice, not a consequence of two rows. -/
noncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)

/- Rational family (a*t+b)/(t+r), identified from three calorimetric
   values. First differences determine r; two equations then give a,b.
   This is an empirical family choice, not a claimed law of electrolytes. -/
noncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=
  let d1 := y25-y20
  let d2 := y30-y25
  let r := (30*d2-20*d1)/(d1-d2)
  let a := (y25*(25+r)-y20*(20+r))/5
  let b := y20*(20+r)-20*a
  (a*t+b)/(t+r)

/- Apparent molar capacity J/(mol K), fitted to Parker table II C.
   Affine composition interpolation and extension to 19..100 C are
   independent empirical choices, not certified consequences of the data. -/
noncomputable def apparentCapacity (t : ℝ) : ℝ :=
  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +
    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)

lemma capacity_formula : ∀ t : ℝ,
    apparentCapacity t =
      4.184*((1-blend)*((-13*t-2314)/(3*t+70)) +
        blend*((2*t-1275)/(t+45))) := by
  intro t
  unfold apparentCapacity calorimetricCurve
  norm_num
  have hratio : (-(13/3*t) + -(2314/3))/(t+70/3) =
      (-(13*t)-2314)/(3*t+70) := by
    field_simp
    <;> ring
  rw [hratio]
  ring

def netPower (W k t : ℝ) : ℝ := W - k * (t - 20)
/- F,G are inverse first-law time primitives for water and brine. -/
noncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=
  F x - F 20 + G B - G (z x)

/- Identification, not hand-picked rational parameters: multiplying
   y=(a*t+b)/(t+r) by its denominator gives a linear identification system.
   These implications uniquely solve that system for both compositions. -/
lemma calorimetric_identification :
    ∀ a b r : ℝ,
    (-19.8)*(20+r)=a*20+b → (-18.2)*(25+r)=a*25+b →
    (-16.9)*(30+r)=a*30+b → a = -13/3 ∧ b = -2314/3 ∧ r = 70/3 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma calorimetric_identification_upper :
    ∀ a b r : ℝ,
    (-19)*(20+r)=a*20+b → (-17.5)*(25+r)=a*25+b →
    (-16.2)*(30+r)=a*30+b → a = 2 ∧ b = -1275 ∧ r = 45 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma composition_inference :
    waterMass = 0.99820675 ∧ 0 < saltMoles ∧ saltMoles < 0.18 ∧
    0 ≤ blend ∧ blend ≤ 1 := by
  norm_num [waterMass, saltMoles, blend]

/- Rigorous bounds on the DECLARED rational family, not measured error bars.
   Two chords bound the concave capacity curves from below. -/
lemma capacity_bounds :
    ∀ t : ℝ, t ∈ Set.Icc 19 100 →
    -100 ≤ apparentCapacity t ∧ apparentCapacity t ≤ 0 ∧
    (25 ≤ t → t ≤ 60 → -77 + (25/35)*(t-25) ≤ apparentCapacity t) ∧
    (60 ≤ t → -52 + (11/40)*(t-60) ≤ apparentCapacity t) := by
  intro t ht
  obtain ⟨hm, hn, hnhi, hw, hw1⟩ := composition_inference
  have hd : 0 < 3*t+70 := by linarith [ht.1]
  have he : 0 < t+45 := by linarith [ht.1]
  have hlo : -100/4.184 ≤ (-13*t-2314)/(3*t+70) := by
    apply (le_div_iff₀ hd).2
    nlinarith [ht.1]
  have hup : -100/4.184 ≤ (2*t-1275)/(t+45) := by
    apply (le_div_iff₀ he).2
    nlinarith [ht.1]
  have hln : (-13*t-2314)/(3*t+70) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.1]) (le_of_lt hd)
  have hun : (2*t-1275)/(t+45) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.2]) (le_of_lt he)
  have combine : ∀ l, l ≤ 4.184*((-13*t-2314)/(3*t+70)) →
      l ≤ 4.184*((2*t-1275)/(t+45)) → l ≤ apparentCapacity t := by
    intro l hl hu
    rw [capacity_formula]
    nlinarith [mul_nonneg (sub_nonneg.mpr hw1) (sub_nonneg.mpr hl),
      mul_nonneg hw (sub_nonneg.mpr hu)]
  refine ⟨combine (-100) (by nlinarith) (by nlinarith), ?_, ?_, ?_⟩
  · rw [capacity_formula]
    nlinarith [mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hw1) hln,
      mul_nonpos_of_nonneg_of_nonpos hw hun]
  · intro h25 h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
  · intro h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith

/- Differential comparison integrates an inequality without assuming
   numerical quadrature or replacing a secant by a local heat capacity. -/
lemma differential_comparison :
    ∀ (f g : ℝ → ℝ) (df dg : ℝ → ℝ) (a b : ℝ), a ≤ b →
    (∀ t ∈ Set.Icc a b, HasDerivAt f (df t) t) →
    (∀ t ∈ Set.Icc a b, HasDerivAt g (dg t) t) →
    (∀ t ∈ Set.Icc a b, dg t ≤ df t) →
    g b - g a ≤ f b - f a := by
  intro f g df dg a b hab hf hg hle
  have hm : MonotoneOn (fun t => f t - g t) (Set.Icc a b) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro t ht; exact ((hf t ht).sub (hg t ht)).continuousAt.continuousWithinAt
    · intro t ht; exact ((hf t (interior_subset ht)).sub (hg t (interior_subset ht))).hasDerivWithinAt
    · intro t ht; exact sub_nonneg.mpr (hle t (interior_subset ht))
  have h := hm ⟨le_rfl,hab⟩ ⟨hab,le_rfl⟩ hab
  linarith

/- d is enthalpy of brine minus original water and stored 20 C solid,
   per mole. I is solid sensible enthalpy 20->25 C. Positivity alone
   suffices: no extrapolated solid Cp or numerical solid integral is used.
   Parker anchor 928 cal/mol + affine finite-composition 87..88 cal/mol.
   d'=absolute apparent capacity is Kirchhoff's law with fixed solid. -/
lemma material_enthalpy_positive :
    ∀ (d : ℝ → ℝ) (I H : ℝ), 0 ≤ I → 923 ≤ H →
    d 25 = 4.184*(H+87+blend)+I →
    (∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t) →
    ∀ t ∈ Set.Icc 20 100, 100 < d t := by
  intro d I H hI hH ha hd t ht
  have hanchor : 4225 ≤ d 25 := by
    have hw := composition_inference.2.2.2.1
    linarith
  have hdec : ∀ a b : ℝ, 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a := by
    intro a b hal hbh hab
    have h := differential_comparison (fun x => -d x) (fun _ => 0)
      (fun x => -apparentCapacity x) (fun _ => 0) a b hab
      (by intro x hx; exact (hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩).neg)
      (by intro x hx; exact hasDerivAt_const x 0)
      (by intro x hx; exact neg_nonneg.mpr (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.1)
    linarith
  have hfirst : d 25 - 2257.5 ≤ d 60 := by
    have h := differential_comparison d
      (fun x => -77*(x-25)+(25/70)*(x-25)^2)
      apparentCapacity (fun x => -77+(25/35)*(x-25)) 25 60 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 25).const_mul (-77) |>.add
            ((((hasDerivAt_id x).sub_const 25).pow 2).const_mul (25/70)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.1 hx.1 hx.2)
    norm_num at h; linarith
  have hsecond : d 60 - 1860 ≤ d 100 := by
    have h := differential_comparison d
      (fun x => -52*(x-60)+(11/80)*(x-60)^2)
      apparentCapacity (fun x => -52+(11/40)*(x-60)) 60 100 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 60).const_mul (-52) |>.add
            ((((hasDerivAt_id x).sub_const 60).pow 2).const_mul (11/80)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.2 hx.1)
    norm_num at h; linarith
  have hend := hdec t 100 (by linarith [ht.1]) le_rfl ht.2
  linarith

/- The shared loss law derives a power change from the mixing jump;
   no independent before/after heating powers are introduced. -/
lemma newtonian_power_change : ∀ W k x z : ℝ,
    netPower W k z - netPower W k x = k*(x-z) := by
  intro W k x z
  unfold netPower
  ring

/- Variable component storage, J/K: liquid-water specific Cp cw in
   J/(kg K), plus nonnegative pot capacity p in J/K. -/
noncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=
  waterMass * cw t + p t

/- Scientific conclusion. All thermodynamic and first-law premises are
   visible. z is the differentiable, liquid-valued mixing solution;
   its existence/phase admissibility is an exposed physical guard.
   No boiling dwell is allowed: addition x ends at pure-water onset B0.
   The recommendation is conditional on the empirical rational family,
   its composition interpolation and its full-temperature applicability. -/
theorem salt_timing_answer :
    ∀ (U V cw p F G z : ℝ → ℝ) (K I H W k B0 B x : ℝ),
    ((0 : ℕ) : ℝ) ≤ I → ((923 : ℕ) : ℝ) ≤ H → H ≤ ((933 : ℕ) : ℝ) →
    V ((25 : ℕ) : ℝ) - U ((25 : ℕ) : ℝ) - K = saltMoles * (4.184*(H+((87 : ℕ) : ℝ)+blend)+I) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), ((4000 : ℕ) : ℝ) ≤ cw t ∧ ((0 : ℕ) : ℝ) ≤ p t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), HasDerivAt U (waterCapacity cw p t) t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ),
      HasDerivAt V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) →
    ((20 : ℕ) : ℝ) ≤ B0 → B0 ≤ B → B ≤ ((100 : ℕ) : ℝ) → ((0 : ℕ) : ℝ) < k → k*(B-((20 : ℕ) : ℝ)) < W →
    (∀ y, V (z y) = U y + K) →
    (∀ y ∈ Set.Icc ((20 : ℕ) : ℝ) B0, z y ∈ Set.Icc ((19 : ℕ) : ℝ) B ∧ DifferentiableAt ℝ z y) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) B,
      HasDerivAt F (waterCapacity cw p t / netPower W k t) t ∧
      HasDerivAt G ((waterCapacity cw p t + saltMoles * apparentCapacity t) /
        netPower W k t) t) →
    x ∈ Set.Icc ((20 : ℕ) : ℝ) B0 →
    z x < x ∧
    netPower W k (z x) - netPower W k x = k*(x-z x) ∧
    netPower W k x < netPower W k (z x) ∧
    totalTime F G z B ((20 : ℕ) : ℝ) ≤ totalTime F G z B x := by
  intro U V cw p F G z K I H W k B0 B x hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx
  norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV hB0 hB0B hB hk hW hmix hz hFG hx ⊢
  obtain ⟨hmass, hn, hnhi, hw, hw1⟩ := composition_inference
  have hN : saltMoles ≠ 0 := ne_of_gt hn
  have hstorage : ∀ t ∈ Set.Icc 19 100,
      0 < waterCapacity cw p t ∧
      0 < waterCapacity cw p t + saltMoles * apparentCapacity t := by
    intro t ht
    obtain ⟨hcw, hp⟩ := hcomponents t ht
    have hcp := (capacity_bounds t ht).1
    have hbound := mul_nonneg (le_of_lt hn) (show 0 ≤ apparentCapacity t + 100 by linarith)
    unfold waterCapacity
    rw [hmass]
    constructor <;> nlinarith
  have hd : ∀ t ∈ Set.Icc 20 100,
      100 < (V t - U t - K) / saltMoles := by
    apply material_enthalpy_positive (fun t => (V t-U t-K)/saltMoles) I H hI hH
    · rw [ha]; field_simp <;> norm_num <;> ring
    · intro t ht
      convert (((hV t ht).sub (hU t ht)).sub_const K).div_const saltMoles using 1
      field_simp
      ring
  have hVm : StrictMonoOn V (Set.Icc 19 100) := by
    apply strictMonoOn_of_hasDerivWithinAt_pos (convex_Icc _ _)
    · intro t ht; exact (hV t ht).continuousAt.continuousWithinAt
    · intro t ht; exact (hV t (interior_subset ht)).hasDerivWithinAt
    · intro t ht; exact (hstorage t (interior_subset ht)).2
  have hcool : ∀ y ∈ Set.Icc 20 B0, z y < y := by
    intro y hy
    have hy100 : y ∈ Set.Icc 19 100 := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨(hz y hy).1.1,by linarith [(hz y hy).1.2]⟩
    have hdpos := (lt_div_iff₀ hn).1 (hd y ⟨hy.1,by linarith [hy.2]⟩)
    by_contra h
    have hle : V y ≤ V (z y) := hVm.monotoneOn hy100 hz100 (le_of_not_gt h)
    rw [hmix y] at hle
    nlinarith
  have hpower : ∀ t ∈ Set.Icc 19 B, 0 < netPower W k t := by
    intro t ht
    unfold netPower
    nlinarith [ht.2]
  have hder : ∀ y ∈ Set.Icc 20 B0,
      HasDerivAt (totalTime F G z B)
        (waterCapacity cw p y *
          (1 / netPower W k y - 1 / netPower W k (z y))) y := by
    intro y hy
    have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hy100 : y ∈ Set.Icc 19 100 := ⟨hyB.1,by linarith [hyB.2]⟩
    have hzB := (hz y hy).1
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨hzB.1,by linarith [hzB.2]⟩
    have hchain := (hV (z y) hz100).comp y (hz y hy).2.hasDerivAt
    have hid : (fun t => V (z t)) = (fun t => U t + K) := funext hmix
    change HasDerivAt (fun t => V (z t)) _ y at hchain
    rw [hid] at hchain
    have he := hchain.unique ((hU y hy100).add_const K)
    have ht := (((hFG y hyB).1.sub_const (F 20)).add_const (G B)).sub
      ((hFG (z y) hzB).2.comp y (hz y hy).2.hasDerivAt)
    change HasDerivAt (totalTime F G z B) _ y at ht
    convert ht using 1
    have hny := ne_of_gt (hpower y hyB)
    have hnz := ne_of_gt (hpower (z y) hzB)
    field_simp [hny, hnz]
    have he' := congrArg (fun a : ℝ => netPower W k y * a) he
    nlinarith only [he']
  have hmon : MonotoneOn (totalTime F G z B) (Set.Icc 20 B0) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy; exact (hder y hy).continuousAt.continuousWithinAt
    · intro y hy; exact (hder y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hyI := interior_subset hy
      have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hyI.1],by linarith [hyI.2]⟩
      have hny := hpower y hyB
      have hnz := hpower (z y) (hz y hyI).1
      have horder : netPower W k y ≤ netPower W k (z y) := by
        unfold netPower; nlinarith [hcool y hyI]
      have hrecip : 1 / netPower W k (z y) ≤ 1 / netPower W k y :=
        one_div_le_one_div_of_le hny horder
      exact mul_nonneg (le_of_lt (hstorage y ⟨hyB.1,by linarith [hyB.2]⟩).1)
        (sub_nonneg.mpr hrecip)
  refine ⟨hcool x hx, newtonian_power_change W k x (z x), ?_,
    hmon ⟨le_rfl,hB0⟩ hx hx.1⟩
  unfold netPower
  nlinarith [hcool x hx]
checks/e19bacdc762e44f8bb76c4620e9c4221/submitted.lean
import Mathlib.Analysis.Calculus.Deriv.MeanValue
import Mathlib.Analysis.Calculus.Deriv.Mul
import Mathlib.Analysis.Calculus.Deriv.Pow
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Ring
import Mathlib.Tactic.NormNum

/- Volume in litres, density in g/cm³, result in kg. -/
noncomputable def waterMass : ℝ := 1 * 1000 * 0.99820675 / 1000
noncomputable def saltMoles : ℝ := 10 / 58.443
/- Affine composition coordinate between Parker's measured molalities.
   Affinity in composition is a modeling choice, not a consequence of two rows. -/
noncomputable def blend : ℝ := (saltMoles / waterMass - 0.1388) / (0.1850 - 0.1388)

/- Rational family (a*t+b)/(t+r), identified from three calorimetric
   values. First differences determine r; two equations then give a,b.
   This is an empirical family choice, not a claimed law of electrolytes. -/
noncomputable def calorimetricCurve (y20 y25 y30 t : ℝ) : ℝ :=
  let d1 := y25-y20
  let d2 := y30-y25
  let r := (30*d2-20*d1)/(d1-d2)
  let a := (y25*(25+r)-y20*(20+r))/5
  let b := y20*(20+r)-20*a
  (a*t+b)/(t+r)

/- Apparent molar capacity J/(mol K), fitted to Parker table II C.
   Affine composition interpolation and extension to 19..100 C are
   independent empirical choices, not certified consequences of the data. -/
noncomputable def apparentCapacity (t : ℝ) : ℝ :=
  4.184 * ((1-blend)*calorimetricCurve (-19.8) (-18.2) (-16.9) t +
    blend*calorimetricCurve (-19) (-17.5) (-16.2) t)

lemma capacity_formula : ∀ t : ℝ,
    apparentCapacity t =
      4.184*((1-blend)*((-13*t-2314)/(3*t+70)) +
        blend*((2*t-1275)/(t+45))) := by
  intro t
  unfold apparentCapacity calorimetricCurve
  norm_num
  have hratio : (-(13/3*t) + -(2314/3))/(t+70/3) =
      (-(13*t)-2314)/(3*t+70) := by
    field_simp
    <;> ring
  rw [hratio]
  ring

def netPower (W k t : ℝ) : ℝ := W - k * (t - 20)
/- F,G are inverse first-law time primitives for water and brine. -/
noncomputable def totalTime (F G z : ℝ → ℝ) (B x : ℝ) : ℝ :=
  F x - F 20 + G B - G (z x)

/- Identification, not hand-picked rational parameters: multiplying
   y=(a*t+b)/(t+r) by its denominator gives a linear identification system.
   These implications uniquely solve that system for both compositions. -/
lemma calorimetric_identification :
    ∀ a b r : ℝ,
    (-19.8)*(20+r)=a*20+b → (-18.2)*(25+r)=a*25+b →
    (-16.9)*(30+r)=a*30+b → a = -13/3 ∧ b = -2314/3 ∧ r = 70/3 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma calorimetric_identification_upper :
    ∀ a b r : ℝ,
    (-19)*(20+r)=a*20+b → (-17.5)*(25+r)=a*25+b →
    (-16.2)*(30+r)=a*30+b → a = 2 ∧ b = -1275 ∧ r = 45 := by
  intros; constructor
  · linarith
  constructor <;> linarith

lemma composition_inference :
    waterMass = 0.99820675 ∧ 0 < saltMoles ∧ saltMoles < 0.18 ∧
    0 ≤ blend ∧ blend ≤ 1 := by
  norm_num [waterMass, saltMoles, blend]

/- Rigorous bounds on the DECLARED rational family, not measured error bars.
   Two chords bound the concave capacity curves from below. -/
lemma capacity_bounds :
    ∀ t : ℝ, t ∈ Set.Icc 19 100 →
    -100 ≤ apparentCapacity t ∧ apparentCapacity t ≤ 0 ∧
    (25 ≤ t → t ≤ 60 → -77 + (25/35)*(t-25) ≤ apparentCapacity t) ∧
    (60 ≤ t → -52 + (11/40)*(t-60) ≤ apparentCapacity t) := by
  intro t ht
  obtain ⟨hm, hn, hnhi, hw, hw1⟩ := composition_inference
  have hd : 0 < 3*t+70 := by linarith [ht.1]
  have he : 0 < t+45 := by linarith [ht.1]
  have hlo : -100/4.184 ≤ (-13*t-2314)/(3*t+70) := by
    apply (le_div_iff₀ hd).2
    nlinarith [ht.1]
  have hup : -100/4.184 ≤ (2*t-1275)/(t+45) := by
    apply (le_div_iff₀ he).2
    nlinarith [ht.1]
  have hln : (-13*t-2314)/(3*t+70) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.1]) (le_of_lt hd)
  have hun : (2*t-1275)/(t+45) ≤ 0 :=
    div_nonpos_of_nonpos_of_nonneg (by linarith [ht.2]) (le_of_lt he)
  have combine : ∀ l, l ≤ 4.184*((-13*t-2314)/(3*t+70)) →
      l ≤ 4.184*((2*t-1275)/(t+45)) → l ≤ apparentCapacity t := by
    intro l hl hu
    rw [capacity_formula]
    nlinarith [mul_nonneg (sub_nonneg.mpr hw1) (sub_nonneg.mpr hl),
      mul_nonneg hw (sub_nonneg.mpr hu)]
  refine ⟨combine (-100) (by nlinarith) (by nlinarith), ?_, ?_, ?_⟩
  · rw [capacity_formula]
    nlinarith [mul_nonpos_of_nonneg_of_nonpos (sub_nonneg.mpr hw1) hln,
      mul_nonpos_of_nonneg_of_nonpos hw hun]
  · intro h25 h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-25)*(60-t) := mul_nonneg (by linarith) (by linarith)
      norm_num at *
      nlinarith
  · intro h60
    apply combine
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ hd).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith
    · rw [← mul_div_assoc]
      apply (le_div_iff₀ he).2
      have hprod : 0 ≤ (t-60)*(100-t) := mul_nonneg (by linarith) (by linarith [ht.2])
      norm_num at *
      nlinarith

/- Differential comparison integrates an inequality without assuming
   numerical quadrature or replacing a secant by a local heat capacity. -/
lemma differential_comparison :
    ∀ (f g : ℝ → ℝ) (df dg : ℝ → ℝ) (a b : ℝ), a ≤ b →
    (∀ t ∈ Set.Icc a b, HasDerivAt f (df t) t) →
    (∀ t ∈ Set.Icc a b, HasDerivAt g (dg t) t) →
    (∀ t ∈ Set.Icc a b, dg t ≤ df t) →
    g b - g a ≤ f b - f a := by
  intro f g df dg a b hab hf hg hle
  have hm : MonotoneOn (fun t => f t - g t) (Set.Icc a b) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro t ht; exact ((hf t ht).sub (hg t ht)).continuousAt.continuousWithinAt
    · intro t ht; exact ((hf t (interior_subset ht)).sub (hg t (interior_subset ht))).hasDerivWithinAt
    · intro t ht; exact sub_nonneg.mpr (hle t (interior_subset ht))
  have h := hm ⟨le_rfl,hab⟩ ⟨hab,le_rfl⟩ hab
  linarith

/- d is enthalpy of brine minus original water and stored 20 C solid,
   per mole. I is solid sensible enthalpy 20->25 C. Positivity alone
   suffices: no extrapolated solid Cp or numerical solid integral is used.
   Parker anchor 928 cal/mol + affine finite-composition 87..88 cal/mol.
   d'=absolute apparent capacity is Kirchhoff's law with fixed solid. -/
lemma material_enthalpy_positive :
    ∀ (d : ℝ → ℝ) (I H : ℝ), 0 ≤ I → 923 ≤ H →
    d 25 = 4.184*(H+87+blend)+I →
    (∀ t ∈ Set.Icc 19 100, HasDerivAt d (apparentCapacity t) t) →
    ∀ t ∈ Set.Icc 20 100, 100 < d t := by
  intro d I H hI hH ha hd t ht
  have hanchor : 4225 ≤ d 25 := by
    have hw := composition_inference.2.2.2.1
    linarith
  have hdec : ∀ a b : ℝ, 19 ≤ a → b ≤ 100 → a ≤ b → d b ≤ d a := by
    intro a b hal hbh hab
    have h := differential_comparison (fun x => -d x) (fun _ => 0)
      (fun x => -apparentCapacity x) (fun _ => 0) a b hab
      (by intro x hx; exact (hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩).neg)
      (by intro x hx; exact hasDerivAt_const x 0)
      (by intro x hx; exact neg_nonneg.mpr (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.1)
    linarith
  have hfirst : d 25 - 2257.5 ≤ d 60 := by
    have h := differential_comparison d
      (fun x => -77*(x-25)+(25/70)*(x-25)^2)
      apparentCapacity (fun x => -77+(25/35)*(x-25)) 25 60 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 25).const_mul (-77) |>.add
            ((((hasDerivAt_id x).sub_const 25).pow 2).const_mul (25/70)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.1 hx.1 hx.2)
    norm_num at h; linarith
  have hsecond : d 60 - 1860 ≤ d 100 := by
    have h := differential_comparison d
      (fun x => -52*(x-60)+(11/80)*(x-60)^2)
      apparentCapacity (fun x => -52+(11/40)*(x-60)) 60 100 (by norm_num)
      (by intro x hx; exact hd x ⟨by linarith [hx.1],by linarith [hx.2]⟩)
      (by intro x hx; convert ((hasDerivAt_id x).sub_const 60).const_mul (-52) |>.add
            ((((hasDerivAt_id x).sub_const 60).pow 2).const_mul (11/80)) using 1
          · ext v; simp
          · dsimp; ring)
      (by intro x hx; exact (capacity_bounds x ⟨by linarith [hx.1],by linarith [hx.2]⟩).2.2.2 hx.1)
    norm_num at h; linarith
  have hend := hdec t 100 (by linarith [ht.1]) le_rfl ht.2
  linarith

/- The shared loss law derives a power change from the mixing jump;
   no independent before/after heating powers are introduced. -/
lemma newtonian_power_change : ∀ W k x z : ℝ,
    netPower W k z - netPower W k x = k*(x-z) := by
  intro W k x z
  unfold netPower
  ring

/- Variable component storage, J/K: liquid-water specific Cp cw in
   J/(kg K), plus nonnegative pot capacity p in J/K. -/
noncomputable def waterCapacity (cw p : ℝ → ℝ) (t : ℝ) : ℝ :=
  waterMass * cw t + p t

/- Technical library fact, proved rather than assumed. Naming this proof
   prevents the extractor from replacing an implicit continuity proof by
   a fresh auxiliary constant. It adds no physical premise. -/
lemma real_scalar_continuity : ContinuousSMul ℝ ℝ := by infer_instance

/- Scientific conclusion. All thermodynamic and first-law premises are
   visible. z is the differentiable, liquid-valued mixing solution;
   its existence/phase admissibility is an exposed physical guard.
   No boiling dwell is allowed: addition x ends at pure-water onset B0.
   The recommendation is conditional on the empirical rational family,
   its composition interpolation and its full-temperature applicability. -/
theorem salt_timing_answer :
    ∀ (U V cw p F G z : ℝ → ℝ) (K I H W k B0 B x : ℝ),
    ((0 : ℕ) : ℝ) ≤ I → ((923 : ℕ) : ℝ) ≤ H → H ≤ ((933 : ℕ) : ℝ) →
    V ((25 : ℕ) : ℝ) - U ((25 : ℕ) : ℝ) - K = saltMoles * (4.184*(H+((87 : ℕ) : ℝ)+blend)+I) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), ((4000 : ℕ) : ℝ) ≤ cw t ∧ ((0 : ℕ) : ℝ) ≤ p t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ), @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity U (waterCapacity cw p t) t) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) ((100 : ℕ) : ℝ),
      @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity V (waterCapacity cw p t + saltMoles * apparentCapacity t) t) →
    ((20 : ℕ) : ℝ) ≤ B0 → B0 ≤ B → B ≤ ((100 : ℕ) : ℝ) → ((0 : ℕ) : ℝ) < k → k*(B-((20 : ℕ) : ℝ)) < W →
    (∀ y, V (z y) = U y + K) →
    (∀ y ∈ Set.Icc ((20 : ℕ) : ℝ) B0, z y ∈ Set.Icc ((19 : ℕ) : ℝ) B ∧ DifferentiableAt ℝ z y) →
    (∀ t ∈ Set.Icc ((19 : ℕ) : ℝ) B,
      @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity F (waterCapacity cw p t / netPower W k t) t ∧
      @HasDerivAt ℝ _ ℝ _ _ _ real_scalar_continuity G ((waterCapacity cw p t + saltMoles * apparentCapacity t) /
        netPower W k t) t) →
    x ∈ Set.Icc ((20 : ℕ) : ℝ) B0 →
    z x < x ∧
    netPower W k (z x) - netPower W k x = k*(x-z x) ∧
    netPower W k x < netPower W k (z x) ∧
    totalTime F G z B ((20 : ℕ) : ℝ) ≤ totalTime F G z B x := by
  intro U V cw p F G z K I H W k B0 B x hI hH hHhi ha hcomponents hU hV
    hB0 hB0B hB hk hW hmix hz hFG hx
  norm_num only [Nat.cast_ofNat] at hI hH hHhi ha hcomponents hU hV hB0 hB0B hB hk hW hmix hz hFG hx ⊢
  obtain ⟨hmass, hn, hnhi, hw, hw1⟩ := composition_inference
  have hN : saltMoles ≠ 0 := ne_of_gt hn
  have hstorage : ∀ t ∈ Set.Icc 19 100,
      0 < waterCapacity cw p t ∧
      0 < waterCapacity cw p t + saltMoles * apparentCapacity t := by
    intro t ht
    obtain ⟨hcw, hp⟩ := hcomponents t ht
    have hcp := (capacity_bounds t ht).1
    have hbound := mul_nonneg (le_of_lt hn) (show 0 ≤ apparentCapacity t + 100 by linarith)
    unfold waterCapacity
    rw [hmass]
    constructor <;> nlinarith
  have hd : ∀ t ∈ Set.Icc 20 100,
      100 < (V t - U t - K) / saltMoles := by
    apply material_enthalpy_positive (fun t => (V t-U t-K)/saltMoles) I H hI hH
    · rw [ha]; field_simp <;> norm_num <;> ring
    · intro t ht
      convert (((hV t ht).sub (hU t ht)).sub_const K).div_const saltMoles using 1
      field_simp
      ring
  have hVm : StrictMonoOn V (Set.Icc 19 100) := by
    apply strictMonoOn_of_hasDerivWithinAt_pos (convex_Icc _ _)
    · intro t ht; exact (hV t ht).continuousAt.continuousWithinAt
    · intro t ht; exact (hV t (interior_subset ht)).hasDerivWithinAt
    · intro t ht; exact (hstorage t (interior_subset ht)).2
  have hcool : ∀ y ∈ Set.Icc 20 B0, z y < y := by
    intro y hy
    have hy100 : y ∈ Set.Icc 19 100 := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨(hz y hy).1.1,by linarith [(hz y hy).1.2]⟩
    have hdpos := (lt_div_iff₀ hn).1 (hd y ⟨hy.1,by linarith [hy.2]⟩)
    by_contra h
    have hle : V y ≤ V (z y) := hVm.monotoneOn hy100 hz100 (le_of_not_gt h)
    rw [hmix y] at hle
    nlinarith
  have hpower : ∀ t ∈ Set.Icc 19 B, 0 < netPower W k t := by
    intro t ht
    unfold netPower
    nlinarith [ht.2]
  have hder : ∀ y ∈ Set.Icc 20 B0,
      HasDerivAt (totalTime F G z B)
        (waterCapacity cw p y *
          (1 / netPower W k y - 1 / netPower W k (z y))) y := by
    intro y hy
    have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hy.1],by linarith [hy.2]⟩
    have hy100 : y ∈ Set.Icc 19 100 := ⟨hyB.1,by linarith [hyB.2]⟩
    have hzB := (hz y hy).1
    have hz100 : z y ∈ Set.Icc 19 100 := ⟨hzB.1,by linarith [hzB.2]⟩
    have hchain := (hV (z y) hz100).comp y (hz y hy).2.hasDerivAt
    have hid : (fun t => V (z t)) = (fun t => U t + K) := funext hmix
    change HasDerivAt (fun t => V (z t)) _ y at hchain
    rw [hid] at hchain
    have he := hchain.unique ((hU y hy100).add_const K)
    have ht := (((hFG y hyB).1.sub_const (F 20)).add_const (G B)).sub
      ((hFG (z y) hzB).2.comp y (hz y hy).2.hasDerivAt)
    change HasDerivAt (totalTime F G z B) _ y at ht
    convert ht using 1
    have hny := ne_of_gt (hpower y hyB)
    have hnz := ne_of_gt (hpower (z y) hzB)
    field_simp [hny, hnz]
    have he' := congrArg (fun a : ℝ => netPower W k y * a) he
    nlinarith only [he']
  have hmon : MonotoneOn (totalTime F G z B) (Set.Icc 20 B0) := by
    apply monotoneOn_of_hasDerivWithinAt_nonneg (convex_Icc _ _)
    · intro y hy; exact (hder y hy).continuousAt.continuousWithinAt
    · intro y hy; exact (hder y (interior_subset hy)).hasDerivWithinAt
    · intro y hy
      have hyI := interior_subset hy
      have hyB : y ∈ Set.Icc 19 B := ⟨by linarith [hyI.1],by linarith [hyI.2]⟩
      have hny := hpower y hyB
      have hnz := hpower (z y) (hz y hyI).1
      have horder : netPower W k y ≤ netPower W k (z y) := by
        unfold netPower; nlinarith [hcool y hyI]
      have hrecip : 1 / netPower W k (z y) ≤ 1 / netPower W k y :=
        one_div_le_one_div_of_le hny horder
      exact mul_nonneg (le_of_lt (hstorage y ⟨hyB.1,by linarith [hyB.2]⟩).1)
        (sub_nonneg.mpr hrecip)
  refine ⟨hcool x hx, newtonian_power_change W k x (z x), ?_,
    hmon ⟨le_rfl,hB0⟩ hx hx.1⟩
  unfold netPower
  nlinarith [hcool x hx]

accepted