@@ -2,11 +2,11 @@
|
|||||||
|
|
||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { InteractiveCode } from '../../../../node_modules/lean4-infoview/src/infoview/interactiveCode'
|
import { InteractiveCode } from '../../../../node_modules/lean4-infoview/src/infoview/interactiveCode'
|
||||||
import { InteractiveHypothesisBundle, InteractiveHypothesisBundle_nonAnonymousNames, MVarId, TaggedText_stripTags } from '@leanprover/infoview-api'
|
import { InteractiveHypothesisBundle_nonAnonymousNames, MVarId, TaggedText_stripTags } from '@leanprover/infoview-api'
|
||||||
import { WithTooltipOnHover } from '../../../../node_modules/lean4-infoview/src/infoview/tooltips';
|
import { WithTooltipOnHover } from '../../../../node_modules/lean4-infoview/src/infoview/tooltips';
|
||||||
import { EditorContext } from '../../../../node_modules/lean4-infoview/src/infoview/contexts';
|
import { EditorContext } from '../../../../node_modules/lean4-infoview/src/infoview/contexts';
|
||||||
import { Locations, LocationsContext, SelectableLocation } from '../../../../node_modules/lean4-infoview/src/infoview/goalLocation';
|
import { Locations, LocationsContext, SelectableLocation } from '../../../../node_modules/lean4-infoview/src/infoview/goalLocation';
|
||||||
import { InteractiveGoal, InteractiveGoals } from './rpcApi';
|
import { InteractiveGoal, InteractiveGoals, InteractiveHypothesisBundle } from './rpcApi';
|
||||||
import { Hints } from './hints';
|
import { Hints } from './hints';
|
||||||
|
|
||||||
/** Returns true if `h` is inaccessible according to Lean's default name rendering. */
|
/** Returns true if `h` is inaccessible according to Lean's default name rendering. */
|
||||||
@@ -144,20 +144,16 @@ export const Goal = React.memo((props: GoalProps) => {
|
|||||||
if (props.goal.isRemoved) cn += 'b--removed '
|
if (props.goal.isRemoved) cn += 'b--removed '
|
||||||
|
|
||||||
const hints = <Hints hints={goal.hints} />
|
const hints = <Hints hints={goal.hints} />
|
||||||
|
const objectHyps = hyps.filter(hyp => !hyp.isAssumption)
|
||||||
|
const assumptionHyps = hyps.filter(hyp => hyp.isAssumption)
|
||||||
|
|
||||||
if (goal.userName) {
|
return <div className={cn}>
|
||||||
return <details open className={cn}>
|
{goal.userName && <div><strong className="goal-case">case </strong>{goal.userName}</div>}
|
||||||
<summary className='mv1 pointer'>
|
|
||||||
<strong className="goal-case">case </strong>{goal.userName}
|
|
||||||
</summary>
|
|
||||||
{filter.reverse && goalLi}
|
|
||||||
{hyps.map((h, i) => <Hyp hyp={h} mvarId={goal.mvarId} key={i} />)}
|
|
||||||
{!filter.reverse && goalLi}
|
|
||||||
{hints}
|
|
||||||
</details>
|
|
||||||
} else return <div className={cn}>
|
|
||||||
{filter.reverse && goalLi}
|
{filter.reverse && goalLi}
|
||||||
{hyps.map((h, i) => <Hyp hyp={h} mvarId={goal.mvarId} key={i} />)}
|
<div>Objects:</div>
|
||||||
|
{objectHyps.map((h, i) => <Hyp hyp={h} mvarId={goal.mvarId} key={i} />)}
|
||||||
|
<div>Assumptions:</div>
|
||||||
|
{assumptionHyps.map((h, i) => <Hyp hyp={h} mvarId={goal.mvarId} key={i} />)}
|
||||||
{!filter.reverse && goalLi}
|
{!filter.reverse && goalLi}
|
||||||
{hints}
|
{hints}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,28 @@
|
|||||||
import { ContextInfo, InteractiveHypothesisBundle, CodeWithInfos, MVarId } from '@leanprover/infoview-api';
|
/* This file is based on `vscode-lean4/vscode-lean4/src/rpcApi.ts ` */
|
||||||
|
|
||||||
|
import { ContextInfo, FVarId, CodeWithInfos, MVarId } from '@leanprover/infoview-api';
|
||||||
|
|
||||||
export interface GameHint {
|
export interface GameHint {
|
||||||
text: string;
|
text: string;
|
||||||
hidden: boolean;
|
hidden: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface InteractiveHypothesisBundle {
|
||||||
|
/** The pretty names of the variables in the bundle. Anonymous names are rendered
|
||||||
|
* as `"[anonymous]"` whereas inaccessible ones have a `✝` appended at the end.
|
||||||
|
* Use `InteractiveHypothesisBundle_nonAnonymousNames` to filter anonymouse ones out. */
|
||||||
|
names: string[];
|
||||||
|
/** Present since server version 1.1.2. */
|
||||||
|
fvarIds?: FVarId[];
|
||||||
|
type: CodeWithInfos;
|
||||||
|
val?: CodeWithInfos;
|
||||||
|
isInstance?: boolean;
|
||||||
|
isType?: boolean;
|
||||||
|
isAssumption?: boolean;
|
||||||
|
isInserted?: boolean;
|
||||||
|
isRemoved?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export interface InteractiveGoalCore {
|
export interface InteractiveGoalCore {
|
||||||
hyps: InteractiveHypothesisBundle[];
|
hyps: InteractiveHypothesisBundle[];
|
||||||
type: CodeWithInfos;
|
type: CodeWithInfos;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ structure InteractiveHypothesisBundle where
|
|||||||
isInstance? : Option Bool := none
|
isInstance? : Option Bool := none
|
||||||
/-- The hypothesis is a type. -/
|
/-- The hypothesis is a type. -/
|
||||||
isType? : Option Bool := none
|
isType? : Option Bool := none
|
||||||
|
/-- The hypothesis's type is of type `Prop` -/
|
||||||
|
isAssumption? : Option Bool := none
|
||||||
/-- If true, the hypothesis was not present on the previous tactic state.
|
/-- If true, the hypothesis was not present on the previous tactic state.
|
||||||
Only present in tactic-mode goals. -/
|
Only present in tactic-mode goals. -/
|
||||||
isInserted? : Option Bool := none
|
isInserted? : Option Bool := none
|
||||||
@@ -123,10 +125,11 @@ def addInteractiveHypothesisBundle (hyps : Array InteractiveHypothesisBundle)
|
|||||||
return hyps.push {
|
return hyps.push {
|
||||||
names
|
names
|
||||||
fvarIds
|
fvarIds
|
||||||
type := (← ppExprTagged type)
|
type := (← ppExprTagged type)
|
||||||
val? := (← value?.mapM ppExprTagged)
|
val? := (← value?.mapM ppExprTagged)
|
||||||
isInstance? := if (← isClass? type).isSome then true else none
|
isInstance? := if (← isClass? type).isSome then true else none
|
||||||
isType? := if (← instantiateMVars type).isSort then true else none
|
isType? := if (← instantiateMVars type).isSort then true else none
|
||||||
|
isAssumption? := if (← inferType type).isProp then true else none
|
||||||
}
|
}
|
||||||
|
|
||||||
open Meta in
|
open Meta in
|
||||||
|
|||||||
Reference in New Issue
Block a user