Basics - Data and Functions

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/17

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 4:38 PM on 4/3/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

18 Terms

1
New cards

Rocq Proof Assistant

  • Proof assistant for functional programming

  • Verifies correctness of programs

  • Uses Gallina for definitions, functions, proofs

  • Named after Thierry Coquand

2
New cards

Functional Programming Characteristics

  • Pure functions (no side effects)

  • First-class functions

  • Algebraic data types with pattern matching

  • Polymorphic type systems

  • Easier reasoning, testing, parallel programming

3
New cards

Functional vs Imperative Programming

  • Functional: immutable state, recursion, no side effects
  • Imperative: mutable variables, loops, side effects
  • Functional enables easier reasoning and parallelism
  • Imperative has harder-to-debug state changes
4
New cards

Rocq Basic Workflow

  • Write Rocq code in .v files
  • Process files interactively for definitions and proofs
  • Available in browser, standalone IDE, or VS Code
5
New cards

Inductive Type Definition

  • Defines new types by listing constructors
  • Example: Inductive day : Type := | monday | tuesday …
  • Each constructor creates a value of the type
  • No arguments needed for simple enumerations
6
New cards

Pattern Matching Functions

  • Defined with match statement
  • Must be exhaustive (cover all constructors)
  • Follows structure of data definition
  • Example: nextworkingday (d:day) := match d with … end
7
New cards

Compute Command

  • Evaluates expressions in Rocq
  • Displays both result and type
  • Used for testing
  • Example: Compute (nextworkingday friday) returns ('monday : day')
8
New cards

Example Assertion

  • Records expected result with a name
  • Rocq verifies it with proof tactics
  • Example: Example test: (nextworkingday saturday) = monday.
9
New cards

Proof State Display

  • Shows current proof goal during interaction
  • Example: (1/1) nextworkingday (nextworkingday saturday) = tuesday
  • Transforms step by step until true
10
New cards

Wildcard Pattern

  • Underscore _ matches any value
  • Used when specific value doesn't matter
  • Example: | _ => false matches all remaining cases
11
New cards

Boolean Type in Rocq

  • Built-in Inductive bool : Type := | true | false
  • Defined with pattern matching
  • Example: andb (b1 b2:bool) := match b1 with … end
12
New cards

Custom Notation

  • Defines syntactic sugar for readability
  • Example: Notation "x && y" := (andb x y)
  • Allows writing true && false instead of andb true false
13
New cards

Conditional Expressions

  • if-then-else for boolean pattern matching
  • Must have same type branches
  • Example: def negb' (b:bool) := if b then false else true
14
New cards

Check Command

  • Displays type of an expression
  • Examples: Check true : bool
  • Function types written with arrows
15
New cards

Constructors with Arguments

  • Inductive types can have constructors carrying data
  • Example: Inductive color : Type := | black | white | primary (p : rgb)
  • Primary constructor takes rgb argument
16
New cards

Pattern Matching with Arguments

  • Match on constructors with arguments
  • Use variables or constants
  • Example: | primary red => true | primary _ => false
17
New cards

Modules in Rocq

  • Organize code into named spaces
  • Example: Module Playground
  • Access with dot notation: Playground.foo
18
New cards

Programs Are Data Principle

  • Data has structure; functions follow that structure
  • Inductive types define shapes
  • Functions use pattern matching for processing

Explore top flashcards

flashcards
Semester 1 midterms science
21
Updated 108d ago
0.0(0)
flashcards
Prep Game Notes
31
Updated 435d ago
0.0(0)
flashcards
Gr 11 Bio - Evolution
54
Updated 1081d ago
0.0(0)
flashcards
SIS 342 FINAL EXAM
72
Updated 344d ago
0.0(0)
flashcards
Bio - Exam intra 1
108
Updated 550d ago
0.0(0)
flashcards
Welding Test. Airframe
35
Updated 479d ago
0.0(0)
flashcards
Semester 1 midterms science
21
Updated 108d ago
0.0(0)
flashcards
Prep Game Notes
31
Updated 435d ago
0.0(0)
flashcards
Gr 11 Bio - Evolution
54
Updated 1081d ago
0.0(0)
flashcards
SIS 342 FINAL EXAM
72
Updated 344d ago
0.0(0)
flashcards
Bio - Exam intra 1
108
Updated 550d ago
0.0(0)
flashcards
Welding Test. Airframe
35
Updated 479d ago
0.0(0)